abhinsawant
New member
- Joined
- Apr 14, 2011
- Messages
- 2
- Programming Experience
- Beginner
i have query to create table. i give name to table from text box. but wen i put integer in text box it gives me error as "incorrect syntax near ' 4' ". here 4 is the value which i entered in text box.. my code is as follows
If con.State = ConnectionState.Open Then
con.Close()
End If
con = New SqlConnection("Server=SAWANT-PC\SQLEXPRESS;Database=PR;Trusted_Connection=True")
con.Open()
sqlq = "create table " & CInt(EmpID.Text) & " (myId INTEGER CONSTRAINT PKeyMyId PRIMARY KEY," + "myName CHAR(50), myAddress CHAR(255), myBalance FLOAT)"
cmd = New SqlCommand(sqlq, con)
Try
cmd.ExecuteNonQuery()
Catch ae As SqlException
MessageBox.Show(ae.Message())
End Try
If con.State = ConnectionState.Open Then
con.Close()
End If
con = New SqlConnection("Server=SAWANT-PC\SQLEXPRESS;Database=PR;Trusted_Connection=True")
con.Open()
sqlq = "create table " & CInt(EmpID.Text) & " (myId INTEGER CONSTRAINT PKeyMyId PRIMARY KEY," + "myName CHAR(50), myAddress CHAR(255), myBalance FLOAT)"
cmd = New SqlCommand(sqlq, con)
Try
cmd.ExecuteNonQuery()
Catch ae As SqlException
MessageBox.Show(ae.Message())
End Try