Click here to Skip to main content
15,900,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to update database contents through text boxes in asp.net
Posted
Updated 17-Oct-12 21:30pm
v4
Comments
OriginalGriff 18-Oct-12 3:03am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Somewhere in your code you are using a variable that contains a null - without the relevant code fragment, we can't even begin to guess. If you look at the error message, it should give you a file and a line number - we would need to see the line and some small amount of code round it for context.
Use the "Improve question" widget to edit your question and provide better information.
manak chand 18-Oct-12 3:44am    
please elborate the scenario..
Anele Ngqandu 18-Oct-12 4:06am    
What database you using?

you need to use new keyword while declaring object.
 
Share this answer
 
Comments
MT_ 18-Oct-12 3:21am    
Can you please elaborate your answer a bit more?
C#
SqlConnection myconn;
            //SqlConnection mycomm;
            myconn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Server.MapPath("~\\App_Data\\bhaddal.mdf") + " ;Integrated Security=True;User Instance=True");
            myconn.Open();
            //string q;

            SqlConnection myConn = new SqlConnection(myconn.ConnectionString);

            s= WebConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;

          myconn = new SqlConnection(s);
            myconn.Open();
            cmd = new SqlCommand("update Employee set first='" + TextBox1.Text+ "', secound='" + TextBox2 + "', third='" + TextBox3.Text + "', fourth='" + TextBox5.Text + "', fifth='"  + "' rollno='" + TextBox1.Text + "'", myconn);
            cmd.ExecuteNonQuery();
            //Label1.Text = " Record Updated successfully";
         clearData();
 
Share this answer
 
v4
Comments
AshishChaudha 18-Oct-12 3:20am    
Whats the issue in this??
Dim object As New MyClass()


example:
VB
Dim cmd As SqlCommand
            cmd = New SqlCommand(sSql, Conn, transaction)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900