hi there.
i m trying to write codes for new user to fill in the form, then the new data will into my database,however, my codes doesnt work, i cant figure out what's wrong with my codes.
below are my codes:
Imports System.Data.OleDb
Public Class NewUser
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnCreate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCreate.Click
Dim DBConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:/login_1.mdb")
Dim DBCmd As New OleDbCommand
Try
DBCmd = New OleDbCommand("Insert Into NewUser(UserName,Password,Name,Email) Values (@UserName, @Password, @Name, @Email)", DBConn)
Dim paramusername As New OleDbParameter("@UserName", OleDbType.VarChar, 50)
paramusername.Value = txtNUser
DBCmd.Parameters.Add(paramusername)
Dim parampassword As New OleDbParameter("@Password", OleDbType.VarChar, 50)
parampassword.Value = txtNPwd
DBCmd.Parameters.Add(parampassword)
Dim paramname As New OleDbParameter("@Name", OleDbType.VarChar, 50)
paramname.Value = txtName
DBCmd.Parameters.Add(paramname)
Dim paramemail As New OleDbParameter("@Email", OleDbType.VarChar, 50)
paramemail.Value = txtEmail
DBCmd.Parameters.Add(paramemail)
DBConn.Open()
DBCmd.ExecuteNonQuery()
Response.Write("Updated")
Catch exp As Exception
Response.Write("Failed")
End Try
DBCmd.Dispose()
DBConn.Close()
DBConn = Nothing
End Sub
End Class
there is no error encounter, however,the adding is failed and no new data can be add in.
anyone know what's wrong with my codes?..
thank you.