Imports System.Data.OleDb
Partial Class register
Inherits System.Web.UI.Page
Dim an As New OleDbConnection("provider=micromofy.jet.oledb.4.0;database=" & Server.MapPath("database/Database1.accdb"))
Protected Sub ImageButton1_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton1.Click
Try
Dim cmd As New OleDbCommand("insert into reo{Name,Age,Contact,Gender,Address,Username,Password,Comfirm Password}values{a1,a2,a3,a4,a5,a6,a7,a8}", cn)
cmd.Parameters.AddWithValue("a1", TextBox1)
cmd.Parameters.AddWithValue("a2", TextBox2)
cmd.Parameters.AddWithValue("a3", TextBox3)
cmd.Parameters.AddWithValue("a4", TextBox4)
cmd.Parameters.AddWithValue("a5", TextBox5)
cmd.Parameters.AddWithValue("a6", TextBox6)
cmd.Parameters.AddWithValue("a7", TextBox7)
cmd.Parameters.AddWithValue("a8", TextBox8)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
Label1.Text = "Data Saved"
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
Catch ex As Exception
cn.Close()
Label1.text = ex.Message
End Try
Server.Transfer("Login.aspx")
End Sub
End Class
答案 0 :(得分:0)
如果您的连接字符串已整理好......
Dim cmd As New OleDbCommand("insert into reo (Name,Age,Contact,Gender,Address,Username,Password,[Comfirm Password]) values (@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8)", cn)
cmd.Parameters.AddWithValue("@a1", TextBox1.Text)
等