SqlConnection con = new SqlConnection("Data Source =TWPL-PC\\SQLEXPRESS;Initial Catalog=TWPLSOFTWARE;Integrated security = True");
con.Open();
SqlCommand cmd = new SqlCommand("select IG_ID ,ITEM_GROUP_NAME ,MAIN_GROUP from ITEM_GROUP where ITEM_GROUP_NAME=@ITEM_GROUP_NAME", con);
cmd.Parameters.Add(new SqlParameter("@ITEM_GROUP_NAME", omboBox2.SelectedItem.ToString()));
SqlDataReader dr = cmd.ExecuteReader();
How can I install my program on a different machine when it has an embedded connection string pointing to a database on my own machine? When installed on the other machine it needs to point to its own local instance.
If
TWPL-PCis the name of your machine, then simply change the connection string to:Note the
.instead of the specific machine name – it is a simple shortcut that meanslocalhost(i.e. the current machine).If
TWPL-PCis the name of a server that the instance of SQL Express is installed on then you will need to make sure “the other computer” can see that same server.