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
Vinit Jain
NA
1
1.5k
Solve The code problem
May 20 2013 4:18 AM
i am making a windows form application to insert data. i used service based database for storing the data.
i am using following code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
namespace App4
{
public partial class Form1 : Form
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\db.mdf;Integrated Security=True");
SqlDataAdapter ad = new SqlDataAdapter();
DataSet ds = new DataSet();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
ad.InsertCommand = new SqlCommand("insert into data (name,age,phone) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')", con);
ad.InsertCommand.ExecuteNonQuery();
ad.InsertCommand.Dispose();
con.Close();
ad.SelectCommand = new SqlCommand("select * from data", con);
con.Open();
ad.Fill(ds);
con.Close();
}
}
}
in this code insert command executing and ds is also filling with the last entered data. but main problem is that this data is not showing into the data table.
why?????
please give the sollution for this problem.
Reply
Answers (
4
)
one session per tab of a browser.
i need to know the reference URL