16,554
社区成员
发帖
与我相关
我的任务
分享
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim textWord As String = "text.mdb"
Dim UseWord As String = "C:\test.mdb"
Dim objconnection As OleDbConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objconnection = New OleDbConnection("Provider = Microsoft.JET.OLEDB.4.0;" & "Data source = " & UseWord & ";")
objconnection.Open()
Timer1.Enabled = True
Timer1.Interval = 100
Try
SheetDisplay(grdResults, objconnection)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
txtRecive.Text = grdResults.SelectedCells.Item(1).Value
End Sub
Public Sub SheetDisplay(ByVal grdResults As DataGridView, ByVal objconnection As OleDbConnection)
Dim binding As New BindingSource
Dim SQLString As String = "SELECT * FROM Buffer"
Dim objCommand As New OleDbCommand(SQLString, objconnection)
objCommand.CommandType = CommandType.Text
Dim objDataAdapter As New OleDbDataAdapter
Dim objDataTable As New DataTable
objDataAdapter.SelectCommand = objCommand
objDataAdapter.Fill(objDataTable)
binding.DataSource = objDataTable
grdResults.DataSource = binding
grdResults.MultiSelect = False
grdResults.EditMode = DataGridViewEditMode.EditProgrammatically
grdResults.SelectionMode = DataGridViewSelectionMode.FullRowSelect
binding.MoveLast()
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
SheetDisplay(grdResults, objconnection)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
txtRecive.Text = grdResults.SelectedCells.Item(1).Value
End Sub
End Class
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim textWord As String = "Test.mdb"
Dim UseWord As String = "C:\Test.mdb"
Dim objconnection As OleDbConnection
Dim SQLString As String
Dim R_ID As String = "ABB"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objconnection = New OleDbConnection("Provider = Microsoft.JET.OLEDB.4.0;" & "Data source = " & UseWord & ";")
Try
objconnection.Open()
Catch oledbexceptionErr As OleDbException
MessageBox.Show(oledbexceptionErr.Message, "Access SQL")
Catch InvalidoperationExceptionErr As InvalidOperationException
MessageBox.Show(InvalidoperationExceptionErr.Message, "Access SQL")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SQLString = "INSERT INTO Buffer (R_ID) values('" & TextBox1.Text & "')"
Dim objcommand As OleDbCommand = New OleDbCommand(SQLString, objconnection)
Dim count As Integer = 0
Try
count = objcommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
End Class