Friday, March 23, 2012

Incorrect Syntax near \

Hi

I'm trying to lookup a sigle value from an MS SQL Express database. However, I get an error - Incorrect Syntax near '\' - when executing the code. The line in bold below is what is highlighted on the error I get back. Please Help!!

The code is below

Thanks

Dim oSQLConn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection()oSQLConn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SDCentral.mdf;Integrated Security=True;User Instance=True"oSQLConn.Open() Dim ValExtract As Data.SqlClient.SqlCommand = New Data.SqlClient.SqlCommand("SELECT * FROM ProjectsQRY", oSQLConn) Dim Get1 As Int32 = CInt(ValExtract.ExecuteScalar()) Me.Active1.Text = Get1

oSQLConn.Close()

Hi,

What is the first column in your output, check it, if its any string column that might be the reason.

|||

Hi

Thanks. The first colomn is IsNull([CNT],0)

|||

Is ProjectsQRY a table or a view?

|||

Hi

It was a view, but I found the problem - it was in the view. I was fooled by the obscure error message. Thanks for your help

No comments:

Post a Comment