how to connect database from client machine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bharathk27
    New Member
    • May 2010
    • 16

    #1

    how to connect database from client machine

    i am doing windows application. adminpc has sql server and i am doing an application for client machine from that i have to acees sqldatabase from adminpc. here is the code that i have used.

    string strt201 = "";

    SqlConnection con200 = new SqlConnection(" Data Source =servername; Initial Catalog=cyberst ations; Integrated Security=true;" );
    con200 .Open();
    string strt200 = "select max(uasno) from reports where username='"+tbu sernamec1.Text+ "' and password='"+tbp asswordc1.Text+ "'";
    SqlCommand cmd200 = new SqlCommand(strt 200 , con200);
    SqlDataReader rdr200 = cmd200.ExecuteR eader();
    if(rdr200.HasRo ws)
    {
    while(rdr200.Re ad())
    {
    strt201 = Convert.ToStrin g(rdr200[0]);
    }
    tbusernamec1.Te xt = strt201;
    }
    rdr200.Close();
    con200.Close();

    i tried the above code but it shows login failed to user 'servername\gue st'

    plz anyone could help me

    very urgent

    thanks in advance
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    Well, that seems very clear to me. The credentials you use to connect to the server aren't sufficiƫnt. Set a username and a password in your connectionstrin g and it will work fine if that user has permissions.

    Steven

    Comment

    • bharathk27
      New Member
      • May 2010
      • 16

      #3
      how to do that i am new to this.net

      Comment

      • MrMancunian
        Recognized Expert Contributor
        • Jul 2008
        • 569

        #4
        Look it up on http://www.connectionstrings.com/.

        Steven

        Comment

        • bharathk27
          New Member
          • May 2010
          • 16

          #5
          SqlConnection con200 = new SqlConnection(" Data Source =HELIOS50; Initial Catalog=cyberst ations; Integrated Security=SSPI; Uid=sa; Pwd=mypassword" );

          i tried this but same error follows

          login failed to user'servername \guest'

          Comment

          Working...