I just got back into programming after a two year hiatus. I'm trying to help a buddy get his site off of the ground....
Anyway, I'm developing in ASP.NET using C# and connecting to a MySQL database using the .NET connector provided by Sun. I'm able to successfully establish a connection to a database hosted online and view the data using a GridView object. I'm also able to delete and change rows no problem. However, when I try to insert data into the database, I run into a snag. I get a NullReferenceException. I'm using textboxes for the data to be inserted and a button click event to initiate it. Below is the code for the button:
Expand|Select|Wrap|Line Numbers
- protected void btnDelete_Click(object sender, EventArgs e)
- {
- SqlDataSource1.InsertParameters["user_username"].DefaultValue = this.txtUsername.Text;
- SqlDataSource1.InsertParameters["user_password"].DefaultValue = this.txtPassword.Text;
- SqlDataSource1.InsertParameters["user_email"].DefaultValue = this.txtEmail.Text;
- SqlDataSource1.InsertParameters["user_altEmail"].DefaultValue = this.txtAltEmail.Text;
- SqlDataSource1.InsertParameters["user_securityQuestion1"].DefaultValue = this.txtSecurityQuestion1.Text;
- SqlDataSource1.InsertParameters["user_securityQuestion2"].DefaultValue = this.txtSecurityQuestion2.Text;
- SqlDataSource1.InsertParameters["user_securityQuestion3"].DefaultValue = this.txtSecurityQuestion3.Text;
- }
Thanks!