sql network

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • little83
    New Member
    • Feb 2009
    • 26

    sql network

    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;Initi al Catalog=maindat abase;Integrate d Security=True", listBox1.Select edItem.ToString ());
    SqlConnection connection = new SqlConnection() ;
    connection.Conn ectionString = connectionstr;
    connection.Open ();
    statusStrip1.It ems.Add("Connec tion Is Open");
    connection.Clos e();
    [CODE]
    Any Ideas?
  • little83
    New Member
    • Feb 2009
    • 26

    #2
    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=maindat abase;Integrate d Security=True", listBox1.Select edItem.ToString ());
    SqlConnection connection = new SqlConnection() ;
    connection.Conn ectionString = connectionstr;
    connection.Open ();
    statusStrip1.It ems.Add("Connec tion Is Open");
    connection.Clos e();

    where listbox one contains a list of available servers in the network
    Any ideas?

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Did you add the username that's trying to connect as valid user/login in SQL Server?

      -- CK

      Comment

      Working...