Skip to content
Loading
  • Sundaram Subramanian
    0
    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    String str = "server=MUNESH-PC;database=windowapp;UID=sa;password=123";
    String query = "select * from data";
    SqlConnection con = new SqlConnection(str);
    SqlCommand cmd = new SqlCommand(query, con);
    con.Open();
    DataSet ds = new DataSet();
    MessageBox.Show("connect with sql server");
    con.Close();
    }
    catch (Exception es)
    {
    MessageBox.Show(es.Message);
    }
    }
     
    1) http://www.c-sharpcorner.com/UploadFile/5d065a/tutorial-1sql-server-database-connection-in-window-form/
     
    2) https://www.codeproject.com/Tips/423233/How-to-Connect-to-MySQL-Using-Csharp
     
    Hope this will help. Thanks in advance 
    0
  • Amit Gupta
    0
    Hey
     
    Just you need to change your connection string. Pass IP address of another pc in the server of your connection string.
     
    Rest will all the same.
     
    Good luck!! 
    0
  • Jitendra Shekhawat
    0
    SqlConnection con = new SqlConnection("server=192.168.0.21;Initial Catalog=Database_Name;integrated security = true;");
    0
  • aman deep
    0
    Just Make Few Changes Into  Connection String Like This  If You are Not Using App.Config
    ----------------------------------------------------------------------------------------------------------------------- 
    SqlConnection con = new SqlConnection("server="IP ADDRESS OF THAT COMPUTER GOES HERE ";user=Users;password=password;database=Example1;integrated security = true;")
    0