Hi
i want to create as and when i enter new profile of a person iam using SQL's CREATE TABLE Query, but iam getting error can any one hel me to over come this
Private Sub CreatePerTable() Dim TableID As String TableID = TextPerID.Text Dim cn As New SqlConnection(DataConn) Dim cmd As New SqlCommand("create Table '" & TableID & "' (SLNO INT,NAME varchar(20))", cn) cn.Open() cmd.ExecuteNonQuery() MsgBox("Created Table", MsgBoxStyle.Information, "Confirmation") cn.Close() End Sub
What is the error that you are getting? For starters, I think you need to remove the single quotes from around the table name. If that doesn't help, are you using a User ID to connect to the database that doesn't have Create Table privilidges?
pkvasan
ASKER
iam getting error saying Incorrect syntax near '110'.
110 is the value in TableID, i tried removing single quote but i still get the same error
no i dont use USER ID to connect DB
the same SQL Querry works fine when i use
"create Table Table1 (SLNO INT,NAME varchar(20))", but with passing variable as table name is giving this error
i think DB table doesnt allow the table name with the integer as the initial, try change the name of the table "110" to something like "T110", as long as it is a alphabet initial.