TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Durga Velusamy
NA
318
114.5k
single database with different table
Mar 26 2015 2:29 AM
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 = "";
}
Reply
Answers (
4
)
!!Germany Australia en direct streaming
Why Required Field not working for dropdownlist?