This is a discussion on Re: Weird Provider for SQL Server Error within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> "Disk" is a reserved word. If you can't change the name of the column in the table, then you ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| "Disk" is a reserved word. If you can't change the name of the column in the table, then you need to bracket it whenever you reference it in a SQL statement: Select ..., [Disk], ... This tells the parser to accept it as-is without attempting to parse it. HTH, Bob Barrows zenlikeRage wrote: > hi folks hope you can help with my problem. > im getting this error statement from my vbscript which is connecting > to a SQL server and reading columns from a table into a recordset. > > the error im getting is. > > Microsoft OLE DB Provider for SQL Server: Incorrect syntax near the > keyword 'Disk'. > > Full prog printout. > Connection made... > strSQl set... > .CursorType set... > blah.vbs(57, 4) Microsoft OLE DB Provider for SQL Server: Incorrect > syntax near the keyword 'Disk'. > > if i leave the column name Disk out of the select statement the code > runs perfectly. > all the other column names cause no problem. > any ideas as to why this is happening. > if you need any more info i'll post it up. > > here is the code in question > > Sub openConnection() 'open connection to db providing db & table name > + server > > Set connection=CreateObject("ADODB.Connection") > set objRecSet = CreateObject("ADODB.Recordset") > connection.Open "Provider=sqloledb;Server=(Servername);Database=sm s; > &_ & Trusted_Connection=Yes;dsn=x.dsn; uid=blah; password=blah;" > > WScript.Echo "Connection made..." > > End Sub > > > Sub query(strSQL) > > > with objRecSet > .CursorType = adOpenStatic > WScript.Echo ".CursorType set..." > .Open strSQL, connection > WScript.Echo "COnn set..." > End With > > WScript.Echo "query statement complete..." > > End Sub > > > Function setStrSQL(tableName) > > strSQL = "SELECT Col1,Col2,Col3,Col4, <-other column names > <--notimportant > Col5,Col6,Col7,Disk8,Col9,Col10 <-------- Disk > FROM " & tableName > > setStrSQL = strSQL > WScript.Echo "strSQl set..." > > End Function |
| ||||
| "Bob Barrows" <reb_01501@yahoo.com> wrote in message news:<O#Ij$uhRDHA.2332@TK2MSFTNGP10.phx.gbl>... bob your a legend. worked like a charm. thanks a mill. ray - couldn't test your solution as im using plain vbscript and not asp. thanks for the effort though. > "Disk" is a reserved word. If you can't change the name of the column in the > table, then you need to bracket it whenever you reference it in a SQL > statement: > > Select ..., [Disk], ... > > This tells the parser to accept it as-is without attempting to parse it. > > HTH, > Bob Barrows > > zenlikeRage wrote: > > hi folks hope you can help with my problem. > > im getting this error statement from my vbscript which is connecting > > to a SQL server and reading columns from a table into a recordset. > > > > the error im getting is. > > > > Microsoft OLE DB Provider for SQL Server: Incorrect syntax near the > > keyword 'Disk'. > > > > Full prog printout. > > Connection made... > > strSQl set... > > .CursorType set... > > blah.vbs(57, 4) Microsoft OLE DB Provider for SQL Server: Incorrect > > syntax near the keyword 'Disk'. > > > > if i leave the column name Disk out of the select statement the code > > runs perfectly. > > all the other column names cause no problem. > > any ideas as to why this is happening. > > if you need any more info i'll post it up. > > > > here is the code in question > > > > Sub openConnection() 'open connection to db providing db & table name > > + server > > > > Set connection=CreateObject("ADODB.Connection") > > set objRecSet = CreateObject("ADODB.Recordset") > > connection.Open "Provider=sqloledb;Server=(Servername);Database=sm s; > > &_ & Trusted_Connection=Yes;dsn=x.dsn; uid=blah; password=blah;" > > > > WScript.Echo "Connection made..." > > > > End Sub > > > > > > Sub query(strSQL) > > > > > > with objRecSet > > .CursorType = adOpenStatic > > WScript.Echo ".CursorType set..." > > .Open strSQL, connection > > WScript.Echo "COnn set..." > > End With > > > > WScript.Echo "query statement complete..." > > > > End Sub > > > > > > Function setStrSQL(tableName) > > > > strSQL = "SELECT Col1,Col2,Col3,Col4, <-other column names > > <--notimportant > > Col5,Col6,Col7,Disk8,Col9,Col10 <-------- Disk > > FROM " & tableName > > > > setStrSQL = strSQL > > WScript.Echo "strSQl set..." > > > > End Function |