Unix Technical Forum

Re: Weird Provider for SQL Server Error

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 ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > MS SQL ODBC

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 08:12 PM
Bob Barrows
 
Posts: n/a
Default Re: Weird Provider for SQL Server Error

"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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 08:12 PM
zenlikeRage
 
Posts: n/a
Default Re: Weird Provider for SQL Server Error

"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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:48 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com