How to Connect to SQL server 2005 ???

G

Guest

Dear all I try to retrive a set of data from an sql server 2005 database
with VS 2003

Following code is used :

m_sqlCon.Open()

m_sqlCmdObj = New Data.SqlClient.SqlCommand
m_sqlCmdObj.CommandType = Data.CommandType.Text
m_sqlCmdObj.Connection = m_sqlCon
m_sqlCmdObj.CommandText = m_SqlCmd
m_sqlCmdObj.CommandTimeout = 20

m_SqlAdapter.SelectCommand = m_sqlCmdObj
m_SqlAdapter.Fill(dsReelHist)

The .Open statement suceed
I get a SQL exception error " System error" when filling the dataset...

What is wrong here ?
Does framwork 1.1 is cabable of connection to SQL 2005 ?

regards
serge
 
M

Marina Levit [MVP]

I suspect there is a problem with your query. Put a try/catch around this
code and capture the error message, not what the debugger is saying.
 
W

William \(Bill\) Vaughn

1) VS (any version) can access SQL Server (any version) so this should not
be an issue. The same is true for the 1.1 Framework.
2) Where is the failure occurring? At the Open?
3) Have you figured out how constructors work? When you declare a new
SqlCommand object, you can pass the query and the Connection in one line of
code.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
 
C

Cor Ligthert [MVP]

Serge,

The previous time somebody showed this I missed the answer that could have
been obvious.

The dataset is not declared.
(because you are so complete, the commandtype.text is default by instance).

Cor
 
L

leonaldo.franco

Hey Serge :

Can I see the whole code, because it seems that your query is invalid,
or any object was not declared.

Leo Franco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top