Click to See Complete Forum and Search --> : Sql Error


taurus24
03-08-2005, 12:54 AM
Hi, i m trying to create table in my SQL server. but it is not creating table instead it shows this error below. it is suppose to create table base on the stradmin.


Server was unable to process request. --> Line 1: Incorrect syntax near '020700N'.

This is my code:

Public Function SetBlackListInfor(ByVal stradmin As String) As DataSet

Dim ds As New DataSet
setUpDatabase()
sqlCmd.CommandText = "CREATE TABLE '" & stradmin & "'(BAdmin varchar(10) NOT NULL)"

Dim da As New SqlDataAdapter(sqlCmd)
da.Fill(ds)
Return ds
sqlConn.Close()
End Function

buntine
03-08-2005, 02:42 AM
Try:

sqlCmd.CommandText = "CREATE TABLE " & stradmin & " (BAdmin varchar(10) NOT NULL)"

It seems this is actually an ASP.NET question. I will wait for your reply and move this thread if the issue is not resolved.

Regards.

taurus24
03-08-2005, 05:04 AM
okay i have tried tat SQL before...
For Example,
stradmin = 022202H, so if i take out the single quote it will only retrieve 022202 without the letter at the end.

buntine
03-08-2005, 05:41 AM
It shoiuld be a string.

stradmin = "022202H"

Or

stradmin = 022202H
strAdmin = CStr(strAdmin)

Regards.

taurus24
03-10-2005, 11:33 PM
i tried converting in my sql statement but still the same error!

code:
sqlCmd.CommandText = "CREATE TABLE '" & Cstr(stradmin) & "'(BAdmin varchar(10) NOT NULL)"

wad should i do next?