Microsoft.Data.Odbc.OdbcException: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]

Hi Everybody,


On localhost this application works fine but when I put on remote server. I am getting following errors. For both localhost and server, I am using same remote sql 2000. I will appreciate any help.
Thanks,
Arif

Server Error in '/' Application.
--------------------------------------------------------------------------------
ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ')'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.Data.Odbc.OdbcException: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ')'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:

[OdbcException: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ')'.]
Microsoft.Data.Odbc.OdbcConnection.HandleError(IntPtr hHandle, SQL_HANDLE hType, RETCODE retcode) +27
Microsoft.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method) +838
Microsoft.Data.Odbc.OdbcCommand.ExecuteNonQuery() +80
Calgary.venues.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Calgary\Site\venues\venues.aspx.vb:32
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731


Software Development

http://aulia.com

0
aulia
12/10/2003 3:07:13 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

5 Replies
2951 Views

Similar Articles

[PageSpeed] 28

are you using ODBC to connect to sql server ??if so you should be using sqlclient...its much better integrated into .net...

hth
***********************
Dinakar Nethi
Life is short. Enjoy it.
***********************
0
ndinakar
12/10/2003 6:12:12 PM
Hi,

Thanks for reply. I am doing some maintaince on some existing code. Somebody else wrote the code. Application was runing againt MySQL but I am converting over to SQL 2000.

Thanks,
Arif

Software Development

http://aulia.com

0
aulia
12/11/2003 1:10:28 PM
Here are the Code: Its failing on myCommand.ExecuteNonQuery(). It was working fine before. Even now its works fine on my localhost.

Thanks,
Arif

Dim strSQL As String
' strSQL = "SELECT * from tblbands where name = "
' strSQL = "SELECT tblAdminUsers_ID as Expr1, RealName as Expr2 From tblAdminUsers order by RealName"
Dim sBandName = Request("bandID")
If sBandName = "09" Then
strSQL = "select name, location, genre from tblbands,tbllocation,tblgenre
WHERE(tblbands.Location_ID = tbllocation.tblLocation_ID)AND tblgenre.tblGenre_ID =
tblbands.Genre_ID and tblbands.isapproved=1 and tblbands.name between '0'
AND '9'ORDER BY name "
End If

If sBandName = "AK" Then
strSQL = "select name, location, genre from tblbands,tbllocation,tblgenre
WHERE(tblbands.Location_ID = tbllocation.tblLocation_ID)AND tblgenre.tblGenre_ID =
tblbands.Genre_ID and tblbands.isapproved=1 and tblbands.name between 'A' AND 'K'
ORDER BY name"
End If

If sBandName = "LZ" Then
strSQL = "select name, location, genre from tblbands,tbllocation,tblgenre
WHERE(tblbands.Location_ID = tbllocation.tblLocation_ID)AND tblgenre.tblGenre_ID =
tblbands.Genre_ID and tblbands.isapproved=1 and tblbands.name between 'L' AND 'Z'
ORDER BY name "
End If

Dim myConnString = ConfigurationSettings.AppSettings("ConnectionString")
Dim myConn As New OdbcConnection(myConnString)
Dim myCommand As New OdbcCommand(strSQL, myConn)
myConn.Open()
myCommand.ExecuteNonQuery()
Dim myReader As OdbcDataReader = myCommand.ExecuteReader()
Repeater1.DataSource = myReader
Repeater1.DataBind()
myReader.Close()
myConn.Close()

Software Development

http://aulia.com

0
aulia
12/11/2003 1:12:13 PM
remove tht line...you are already using the execute reader...

comment out this line
myCommand.ExecuteNonQuery()

hth
***********************
Dinakar Nethi
Life is short. Enjoy it.
***********************
0
ndinakar
12/11/2003 3:37:56 PM
Same code was working before. Thanks and let me test again. 


best regards,
arif

Software Development

http://aulia.com

0
aulia
12/11/2003 4:14:17 PM
Reply:

Similar Artilces:

wegconfig connectionstring ADODB System.Data.Odbc error is [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'TSQL'
    <add name="MYADODBCUSTOMERCONNECTIONSTRING" connectionString="Driver={SQL Server};Server=xxx.xxx.xxx.xxx;Database=myDbname;Uid=xxxxx;Pwd=xxxxx" providerName="System.Data.Odbc" />   [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'TSQL'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: [Micros...

Error using OdbcDataReader.ExecuteReader and Parameters...ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the variable
This seems to be a common problem but I have not seen any answers yet on this board.   I am porting over to using odbc because I have no choice with my Hosting company,  I was using basically the same code with the SQLDataReader and SQLCommand object and it was fine.  The below code will generate the error.  Help !! Unexpected exception: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the variable '@Role'.. string sql = String.Empty ;sql = "Select * from Associate where Role=@Role and Exit_Date > @Exit_Date";string connString = getConn...

Why does a simple select query in Microsoft Access return the error [Intersolv][ODBC SQL Server Driver][SQL Server]ct_results(): user api layer: internal client library error: Read from the server has
I have applied the information from support document 10447954 but that does not solve the problem. I am running a simple select query with one criteria from one table. Thanks. ...

[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
Hello All, I'm Getting the following error when calling a dll from my vb.net application. [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. The dll was written in vb6 and accesses a sql db using the following connection string. Public Const GLOBAL_DNS As String = "DSN=TransSrvFinal;UID=sa;PWD=admin;" This DLL works fine when called from other Windows Apps. However I'm now trying to call this dll from with in an asp.net application. I'm using vb.net as the codebehind. I'm a...

[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database requested in login 'WinFM SQL PFS'. Login fails.
HiASP pages were properly connecting to SQL DB until I restored from a backup DB.  As soon as I finished restoring from the backup DB, I am getting the following error message.   I did not make any changes on ASP side.  IIS Server and SQL 2K Server is running on a WIN2K Server Box.Please help.Thank you.HTTP 500.100 - Internal Server Error - ASP errorInternet Information ServicesTechnical Information (for support personnel)Error Type:Microsoft OLE DB Provider for ODBC Drivers (0x80004005)[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database requested in login...

Why does a simple select query in MS Access return the error: [Intersolv][ODBC SQL Server Driver][SQL Server]ct_results(): user api layer: internal client library error: Read from the server has timed
I have applied the information contained in support document 10447954. That did not resolve the problem. I am running a simple query with one criteria and one table Thanks. Hi Bill, The doc refers to a different ODBC driver (for DirectConnect product) so you might have a completely different problem. The message implies you are using ODBC 12.0 (Client Library based) or prior since the message indicates CtLib info. You might want to post more details involved with getting to this error. You also might want to post exact versions of ASE and ODBC driver, including Open ...

This version of Microsoft Sql Server Management Studio can only be used to connect to Sql Server 2000 and Sql Server 2005 servers
When I connect SQL Server 2005 to a remote database i get the error: "This version of Microsoft Sql Server Management Studio can only be used to connect to Sql Server 2000 and Sql Server 2005 servers". Can I confirm it is because: the remote db is of SQL Server 2008? There is a soln mentioned in http://forums.asp.net/t/1324047.aspx Did anybody try this (installing 2008 express: http://www.microsoft.com/express/sql/download/)? I am just checking again, whether it will disturb my existing SQL Server installation, in any means...? Though it is mentioned that it will g...

Microsoft SQL Server Database File (SqlClient) and Microsoft SQL Server (SqlClient)?
hello there is Microsoft SQL Server Database File (SqlClient)(i have created *.mdf Solution of Visual web developer.. righ click, add new item, SQL server database) and Microsoft SQL Server (SqlClient) at server explorer(i have created *.mdf at SQL server management studio) as Modify Connection.. when i create *.mdf at Microsoft SQL Server Database File (SqlClient), i cant see i*.mdf at SQL Server Management Studio. but when i create *.mdf at Microsoft SQL Server (SQLClient), i can see *.mdf SQL Server Management Studio. what is different between Microsoft SQL Server Database File (SqlCli...

Select error: SQLSTATE = 37000 [Microsoft][ODBC SQL Server Driver]Syntax error or access violation
EAS 3.61 C2 with PB 7.03 components, datawindows and nvo's. Powerdynamo 3.5.2. ODBC connection cache that works. This is an application port from a NT 4.0 server to a Window 2000 Server. The whole application works fine, through CORBA and 7 NVO's with at least 20 other datawindows that I have tested. The ONLY offending datawindow causing 'Select error: SQLSTATE = 37000 [Microsoft][ODBC SQL Server Driver]Syntax error or access violation ' is called from a browser **************************************************************************** ********* dwB...

Microsoft SQL Server Developer Edition vs Microsoft SQL Server Express Edition
I have just installed sql server 2005 but, now I have two types of server name: Microsoft SQL Server Developer EditionMicrosoft SQL Server Express Edition Which one should I use? Does it matter??thanks..  Hello, Check SQL Server 2005 Features Comparison: http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx RegardsWindows Hosting ASP.NET | Top ASP.NET Hosts | Dedicated Windows Hosting...

Can microsoft SQL Server 2005 database upgrade to microsoft SQL Server 2008 database?
I have a microsoft SQL Server 2005 database, I don't know how to upgrade the 2005 database to 2008 database, I try to use SQL Server Management Studio Express 2008 to open the 2005 database, it's OK, does it mean that the 2005 database have been upgraded to 2008 database? BTW, is SQL Server 2005 database compatible with SQL Server 2008 database completely?SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip filesSuperCool Random Number Generator Yes. It is compatible. Anyhow go through this url for more informationhttp://msdn.microsoft.com/en-us/li...

'Select error: SQLSTATE = 37000 [Microsoft][ODBC SQL Server Driver]Syntax
This is a cross post. Sorry, but I realized that this is most likely a PowerBuilder issue. EAS 3.61 C2 with PB 7.03 components, datawindows and nvo's. Powerdynamo 3.5.2. ODBC connection cache that works. This is an application port from a NT 4.0 server to a Window 2000 Server. The whole application works fine, through CORBA and 7 NVO's with at least 20 other datawindows that I have tested. The ONLY offending datawindow causing 'Select error: SQLSTATE = 37000 [Microsoft][ODBC SQL Server Driver]Syntax error or access violation ' is called from a browser ...

Microsoft OLE DB Provider for SQL Server error '80004005'. SQL Server does not exist or access denied.
Hi,I have a asp web application, where i use sql server 2005 as backend. This application generates reports . Before i was using SQL Server 2000, now its migrated to 2005. When i generate report for small date range then it works fine. But when the date range is big then around half of the report is generated and the following error is thrown. Microsoft OLE DB Provider for SQL Server error '80004005' [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. ...out.asp, line 405  Am sure the webcode is working fine and am connecting to the Da...

Microsoft SQL Server 6 ODBC Driver
Has anyone managed to run PB applications using the Microsoft SQL Server 6 ODBC Driver? We have found all sorts of problems. For instance, if the user has a default database specified on SQLServer, the driver seems to ignore the database specified in the dbParm and use the default instead. Some problems we have sorted by setting various obscure-looking dbParms, others we are still puzzled by. Has anyone got this working? Is there a list of dbParm values that must be set? Using Intersolv's driver, we get no problems at all. But obviously our customers would rather use the M...

Web resources about - Microsoft.Data.Odbc.OdbcException: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server] - asp.net.sql-datasource

Resources last updated: 1/18/2016 9:58:03 AM