5 pts.
 inserting null record in SQLServer2005 SSMEI through ASP.Net
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

Software/Hardware used:
ASKED: March 17, 2009  5:01 PM
UPDATED: March 17, 2009  7:07 PM

Answer Wiki:
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).
Last Wiki Answer Submitted:  March 17, 2009  7:07 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _