I have 2 PCs.
Let them be pc1 and pc2.
pc1 has Microsoft Visual Studio and SQL server management studio.
I have created a C# windows app form to insert applicant info into a SQL table in pc1. These two are connected "using System.Data.SqlClient" and runs perfectly on pc1.
pc2 only has SQL server management studio, it does not have Microsoft Visual Studio.
The same database and the relevant table is created in pc2.
I want to run my application on pc2 and connect it with the database in pc2.
using System.Data.SqlClient;
namespace Officer_Cadet
{
public partial class Candidates : Form
{
public Candidates()
{
InitializeComponent();
}
SqlConnection con;
SqlCommand cmd;
private void Candidates_Load(object sender, EventArgs e)
{
con = new SqlConnection("Data Source=.;Initial Catalog=Officer__Cadet;Integrated Security=True");
}
private void btn_submit_Click(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand("Insert into CandidateInformation values('" + txt_name.Text + "', '" + txt_address.Text + "', '" + txt_tele1.Text + "', '" + txt_tele2.Text + "', '" + txt_nic.Text + "', '" + txt_mail.Text+ "','" + gender + "' , '" + ch1 + "', '" + ch2 + "', '" + ch3 + "')", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Successfully Registered", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
The above is the code I've used to connect the C# program to the database in pc1.
I tried changing the data source from "." to the server name of pc2 but it didn't work.
I will have to put the files in a pen drive and move to pc2. When I submit the information then it should store in the database in pc2 with the same name.
Please please help me. I am earnestly seeking help.
Thank you in advance.