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 = "";
}
Loading

Manoj BhoirPosted Apr 15, 2015, 4:24 AM
1. Organization Master/Company Master
2. Other Details
And Database table design will look like this
1. Organization Master/Company Master
- CompanyId/OrganizatioId
- Name
- Address and etc
2. Other DetailsAnkur JainPosted Apr 3, 2015, 1:42 AM
please have look on these threads..
http://www.c-sharpcorner.com/UploadFile/5d065a/tutorial-1sql-server-database-connection-in-window-form/
http://www.mindstick.com/Articles/9422cfc8-c2ed-4ec1-9fab-589eb850a863/Insert%20Delete%20Update%20in%20DataGridView%20with%20DataTable%20in%20C#.VR4oG_mUfcg
Durga VelusamyPosted Apr 3, 2015, 1:15 AM
my fields for all table is date, Sub, salary, amount. the fields are common to all table ok.
my database is company: in this i have 3 list like example:xyz textile, abc textile, zxc textile ok.
if i click xyz textile new winform will open in that i have the table fields are date, Sub, salary, amount .
if i click abc textile new winform will open in that i have the table fields are date, Sub, salary, amount .
if i click zxc textile new winform will open in that i have the table fields are date, Sub, salary, amount .
the above 3 company details need to store in separate table. so, how to use single database name for all 3 table name .how to connect winform to database sql server.
Vithal WadjePosted Apr 2, 2015, 4:26 PM