inserting null record in SQLServer2005 SSMEI through ASP.Net

5 pts.
Tags:
SQL Server 2005
SQL Server database
I'm developing my 1st website but when I'm trying to insert data into the SQLServer 2005 it inserting null record. I tried as it is on access. again their is a same problem. Here is my code: Imports System.IO Imports System.Data Imports System.Data.Sql Imports System.Data.SqlClient Public Class contactus Inherits System.Web.UI.Page Protected Sub submit_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.ServerClick Dim con As New SqlConnection("Server=MADHAVI-2C085B0;Integrated Security=SSPI; database=alumniDB") con.Open() Dim str, str1, un, ua, uc, uco, up, ue, ucom As String un = Request.Form.Get("uname") ua = Request.Form.Get("uadd") uc = Request.Form.Get("ucity") uco = Request.Form.Get("ucountry") up = Request.Form.Get("uphoneno") ue = Request.Form.Get("uemail") ucom = Request.Form.Get("ucomments") str = "insert into contactus (UName, UAdd, UCity, UCountry, UPhoneno, UEmail, UComments) values('" & un & "','" & ua & "','" & uc & "','" & uco & "','" & up & "','" & ue & "','" & ucom & "');" Dim cmd As New SqlCommand(str, con) cmd.ExecuteNonQuery() End Sub End Class
ASKED: March 17, 2009  5:01 PM
UPDATED: March 17, 2009  7:07 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

The problem seems to be the construction of the INSERT statement.

To debug the problem, I would display the <i>str</i> variable before executing the command, so you can see the command string that is going to be sent to the database. You could also try to execute that command directly against the database (from management studio or some other tool).

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following