Professional Documents
Culture Documents
IO
Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page
Dim cn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=
F:\WebSite2\Database1.mdb ")
Dim cmd As New OleDbCommand("select * from table1 ", cn)
Dim dr As OleDbDataReader
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
cn.Open()
' MsgBox(GridView1.Rows(e.RowIndex).Cells(1).Text)
' MsgBox(GridView1.DataSourceID.Substring(0))
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventA
rgs) Handles Button1.Click
cmd.CommandText = "insert into table1 values('" & TextBox1.Text.ToString
& "','" & TextBox2.Text.ToString & "','" & TextBox3.Text.ToString & "') "
cmd.ExecuteNonQuery()
MsgBox("save")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventA
rgs) Handles Button2.Click
Dim StrQuery As String
'dr.Read()
StrQuery = " UPDATE table1 SET name='" & TextBox2.Text.Replace("'", "' '
") & "' where MID=" & TextBox1.Text & " "
cmd.CommandText = StrQuery
cmd.ExecuteReader()
'If dr.IsClosed = False Then dr.Close()
'If (cmd.ExecuteNonQuery() > 0) Then
MsgBox("Subject Updated Successfully", vbInformation)
' Else
' MsgBox("Subject Not Updated Successfully", MsgBoxStyle.Critical, "SUBJ
ECT ERROR")
' End If
End Sub
' success(code)
'====================================
'====================================
AccessDataSource1.UpdateCommand = " UPDATE table1 SET " & _
"name='" & e.NewValues.Item(1).ToStrin
g & _
"'where MID=" & GridView1.Rows(e.RowIn
dex).ClientID
End Sub
End Sub
End Class