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
Shivaraj Poojary
NA
92
314.2k
Update
Nov 26 2010 2:35 AM
Hiiii....i have the following code for updating database but am gettin error like "Object reference not set to an instance of an object" please help me..
private void btnUpdate_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
string strConnection = "Integrated Security=SSPI;Persist Security Info=False;User ID=CRYSYS1-DESKTOP\\SQLEXPRESS\\Student;Initial Catalog=ipRFID;Data Source=CRYSYS1-DESKTOP\\SQLEXPRESS";
con = new SqlConnection(strConnection);
con.Open();
string command = "UPDATE TB_EmployeeMaster set Version=@Version,Operating System=@OS,Processor=@Processor,RAM=@RAM where RecId='" + txtID.Text + "'";
cmd = new SqlCommand(command,da.SelectCommand.Connection);
cmd.Parameters.AddWithValue("@RecId", txtID.Text);
cmd.Parameters.AddWithValue("@Version", txtVersion.Text);
cmd.Parameters.AddWithValue("@OS", txtOS.Text);
cmd.Parameters.AddWithValue("@Processor", txtProcessor.Text);
cmd.Parameters.AddWithValue("@RAM", txtRAM.Text);
DataSet ds = new DataSet();
da.UpdateCommand = cmd;
da.Fill(ds, "TB_EmployeeMaster");
da.Update(ds, "TB_EmployeeMaster");
//cmd.ExecuteNonQuery();
MessageBox.Show("Updated");
con.Close();
}
Reply
Answers (
2
)
Codedom memory management
How to change .html extension instead of .aspx