single database with different table
public Form1()
{
InitializeComponent();
BasDataSet dataSet = new BasDataSet();
BasDataSetTableAdapters.deviTableAdapter adapter = new BasDataSetTableAdapters.deviTableAdapter();
adapter.Fill(dataSet.devi);
comboBox1.DataSource = dataSet.devi;
comboBox1.DisplayMember = "CustomerId";
}
private void button1_Click(object sender, EventArgs e)
{
{
SqlConnection con = new SqlConnection(@"server=CSE-PC; integrated security=true; Database=Bas");
con.Open();
SqlCommand cmd1 = new SqlCommand("insert into devi Values('" + comboBox1.Text + "',+'" + comboBox2
.Text + "','" + comboBox3.Text + "','" + comboBox4.Text + "','" + comboBox5.Text + "','" + comboBox6.Text + "','" + comboBox7.Text + "')", con);
cmd1.ExecuteNonQuery();
con.Close();
MessageBox.Show("Added Successfully");
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";
comboBox4.Text = "";
comboBox5.Text = "";
comboBox6.Text = "";
comboBox7.Text = "";
}
in the second form i have same database with different table name
instead of devi table i have table name as durga. this form use the bas database and devi table name its working.
but in the 2nd form bas database and durga table its not working. why? just i have change
the table only in the binding code it shows error at i have drag red background
public Form1()
{
InitializeComponent();
BasDataSet dataSet = new BasDataSet();
BasDataSetTableAdapters.durgaTableAdapter adapter = new BasDataSetTableAdapters.durgaTableAdapter();
adapter.Fill(dataSet.durga);
comboBox1.DataSource = dataSet.durga;
comboBox1.DisplayMember = "CustomerId";
}
private void button1_Click(object sender, EventArgs e)
{
{
SqlConnection con = new SqlConnection(@"server=CSE-PC; integrated security=true; Database=Bas");
con.Open();
SqlCommand cmd1 = new SqlCommand("insert into durga Values('" + comboBox1.Text + "',+'" + comboBox2
.Text + "','" + comboBox3.Text + "','" + comboBox4.Text + "','" + comboBox5.Text + "','" + comboBox6.Text + "','" + comboBox7.Text + "')", con);
cmd1.ExecuteNonQuery();
con.Close();
MessageBox.Show("Added Successfully");
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";
comboBox4.Text = "";
comboBox5.Text = "";
comboBox6.Text = "";
comboBox7.Text = "";
}