I think you will need to post your connection string. I do remember having
the same kind of problem once -however one thing to remember is that when
you programatically do it you can have a very basic connection string. That
said the following connection string was taken from the designer property
for connection string and I used it programmaticall y ok..
this.sqlConnect ion1.Connection String = "workstatio n id=HOST;packet
size=4096;integ rated security=SSPI;d ata source=HOST;per sist security
info=False;init ial catalog=Northwi nd";
this.sqlConnect ion1.Open();
System.Data.Sql Client.SqlComma nd cmd = new
System.Data.Sql Client.SqlComma nd("SELECT TOP 10 * FROM
Orders",sqlConn ection1);
System.Data.Sql Client.SqlDataR eader sr = cmd.ExecuteRead er();
if (sr.Read())
System.Windows. Forms.MessageBo x.Show(sr[0].ToString());
You will see the following is a very basic connection string (all you
need -bearing in mind you are using Integrated security.
cnn.ConnectionS tring =
"Data Source =(local);" +
"Initial Catalog=Northwi nd;" +
"Integrated Security=SSPI";
--
Br,
Mark Broadbent
mcdba , mcse+i
=============
"Alberto" <al*****@nospam .com> wrote in message
news:OZ******** ******@TK2MSFTN GP09.phx.gbl...
I have an object SqlConnection and I changed the connection string
property in the properties windows. The object works fine but if I do the same
declaring the object connection by code and with the same connection
string property, doesn't work. It can't connect to the database.
What's happening??
Thank you