Create/Add New User to the system

AinzFikry

New member
Joined
Nov 26, 2011
Messages
1
Programming Experience
Beginner
Hi everybody. I'm having a problem in creating/adding a new user to the system. The data entered by the user didn't inserted in the database. There are no errors in bugging mode. Please help :(




Protected Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim cmdInsert As OleDbCommand
Dim strInsert As String




Source=" & Request.PhysicalApplicationPath & "\FiST.mdb;")
Dim context As HttpContext


context = HttpContext.Current
url = context.Request.Url.ToString()
IP = context.Request.UserHostAddress.ToString()




logintime = Format(Now(), "hh:mm:ss tt")
logindate = Format(Now(), "dd/MM/yyyy")


If txtUsID.Text = "" And txtName.Text = "" And txtPsswd.Text = "" And txtDptmnt.Text = "" And txtCntct.Text = "" Then
Label7.Text = "Add User FAILED"


Else
strInsert = "INSERT INTO UserData ([User_ID],[User_name],[User_password]) VALUES (@us_ID,@us_name,@us_password)"


cmdInsert = New OleDbCommand(strInsert, con)


cmdInsert.Parameters.AddWithValue("@us_ID", txtUsID.Text)
cmdInsert.Parameters.AddWithValue("@us_name", txtName.Text)
cmdInsert.Parameters.AddWithValue("@us_password", txtPsswd.Text)


Try
con.Open()
cmdInsert.ExecuteNonQuery()
con.Close()
activity = "Succesfully save new user"


Catch ex As Exception
con.Close()
Label7.Text = "Save New User FAILED"
activity = "Save new user failed"
End Try
Response.Redirect("home.aspx")


End If
End Sub
 
What value does ExecuteNonQuery return? If no exception is thrown then it must be succeeding and returning either 1 or 0. The most likely result is that it is returning 1 and the record is being inserted. In that case, it's working and you're just not checking for it properly. To learn how to manage local data files, follow the first link in my signature.
 
Back
Top