By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,806 Members | 1,829 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,806 IT Pros & Developers. It's quick & easy.

sql network

P: 26
Dear all


I got that error when I was trying to connect to a server over IP

Object reference not set to an instance of an object.

the code for that


[code]
string connectionstr = string.Format(@"Data Source=10.192.4.154,1433;Initial Catalog=maindatabase;Integrated Security=True", listBox1.SelectedItem.ToString());
SqlConnection connection = new SqlConnection();
connection.ConnectionString = connectionstr;
connection.Open();
statusStrip1.Items.Add("Connection Is Open");
connection.Close();
[code]
Any Ideas?
Mar 16 '09 #1
Share this Question
Share on Google+
2 Replies


P: 26
i corrected the code ...and i got the following error message

Dear all while i was trying to access sql server i got that problem

Login failed for user ''. The user is not associated with a trusted SQL Server connection

the code is as the following

string connectionstr = string.Format(@"Data Source={0},1433;Initial Catalog=maindatabase;Integrated Security=True",listBox1.SelectedItem.ToString());
SqlConnection connection = new SqlConnection();
connection.ConnectionString = connectionstr;
connection.Open();
statusStrip1.Items.Add("Connection Is Open");
connection.Close();

where listbox one contains a list of available servers in the network
Any ideas?
Mar 16 '09 #2

ck9663
Expert 2.5K+
P: 2,878
Did you add the username that's trying to connect as valid user/login in SQL Server?

-- CK
Mar 16 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.