S
steamratz via DotNetMonster.com
hi all
i'm new with asp.net, i build a page that will show mydatabase
book.mdb,with table called member, it is ok with filling he data but when i
tried to update (with update button)no error but nothing changed in my
database, i've been working this for 9 hour
help me pls
this is my source:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim DBConn As OleDb.OleDbConnection
Dim DBadapter As OleDb.OleDbDataAdapter
Dim dbcommand As OleDb.OleDbCommand
Dim dbread As OleDb.OleDbDataReader
Dim DSdata As New DataSet
'dbcommand = New OleDb.OleDbDataAdapter _
'("Select autonum, book_id, bkname, bkcatagory, bkauthor , bkdesc,
bkprice, bkavailable " _
'& "From book1 Where " _
' & "autonum = " & Request.QueryString("autonum") _
' , DBConn)
DBConn = New OleDb.OleDbConnection
("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("Book.mdb;"))
DBConn.Open()
DBadapter = New OleDb.OleDbDataAdapter("select * from member where
member_id='" & Request.QueryString("member_id") & "'", DBConn)
DBadapter.Fill(DSdata, "member")
TextBox1.Text = DSdata.Tables("member").Rows(0).Item("member_id")
TextBox2.Text = DSdata.Tables("member").Rows(0).Item("mname")
TextBox3.Text = DSdata.Tables("member").Rows(0).Item("mphone")
End Sub
-----------------------------the update button------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim DBConn As New System.Data.OleDb.OleDbConnection
Dim DBadapter As OleDb.OleDbDataAdapter
Dim dbcommand As New System.Data.OleDb.OleDbCommand
Dim DSdata As New DataSet
DBConn = New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("Book.mdb;"))
dbcommand.CommandText = "Update member set mname = '" & TextBox2.Text &
"',mphone= '" & TextBox3.Text & "' Where member_id = '" & TextBox1.Text &
"'"
dbcommand.Connection = DBConn
dbcommand.Connection.Open()
dbcommand.ExecuteNonQuery()
Response.Redirect("member.aspx")
End Sub
i'm new with asp.net, i build a page that will show mydatabase
book.mdb,with table called member, it is ok with filling he data but when i
tried to update (with update button)no error but nothing changed in my
database, i've been working this for 9 hour
help me pls
this is my source:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim DBConn As OleDb.OleDbConnection
Dim DBadapter As OleDb.OleDbDataAdapter
Dim dbcommand As OleDb.OleDbCommand
Dim dbread As OleDb.OleDbDataReader
Dim DSdata As New DataSet
'dbcommand = New OleDb.OleDbDataAdapter _
'("Select autonum, book_id, bkname, bkcatagory, bkauthor , bkdesc,
bkprice, bkavailable " _
'& "From book1 Where " _
' & "autonum = " & Request.QueryString("autonum") _
' , DBConn)
DBConn = New OleDb.OleDbConnection
("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("Book.mdb;"))
DBConn.Open()
DBadapter = New OleDb.OleDbDataAdapter("select * from member where
member_id='" & Request.QueryString("member_id") & "'", DBConn)
DBadapter.Fill(DSdata, "member")
TextBox1.Text = DSdata.Tables("member").Rows(0).Item("member_id")
TextBox2.Text = DSdata.Tables("member").Rows(0).Item("mname")
TextBox3.Text = DSdata.Tables("member").Rows(0).Item("mphone")
End Sub
-----------------------------the update button------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim DBConn As New System.Data.OleDb.OleDbConnection
Dim DBadapter As OleDb.OleDbDataAdapter
Dim dbcommand As New System.Data.OleDb.OleDbCommand
Dim DSdata As New DataSet
DBConn = New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("Book.mdb;"))
dbcommand.CommandText = "Update member set mname = '" & TextBox2.Text &
"',mphone= '" & TextBox3.Text & "' Where member_id = '" & TextBox1.Text &
"'"
dbcommand.Connection = DBConn
dbcommand.Connection.Open()
dbcommand.ExecuteNonQuery()
Response.Redirect("member.aspx")
End Sub