ใส่ชื่อเครื่องแล้วแสดงผลออกมาที่ ชื่อวง กับ server
มันขึ้น error ตรง conn.Open()
Code
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
Public conn As New OleDbConnection
Public Sub connectData() Handles MyBase.Load
Dim connectionString As String = "Provider=Microsoft.ace.OLEDB.12.0;Data Source=.\\twdb.accdb;"
If conn.State = ConnectionState.Closed Then conn.Open()
End Sub
Public Function ExecuteSQL(ByVal prmSQL As String) As Boolean
connectData()
Dim addCom As New OleDbCommand
With addCom
.CommandType = CommandType.Text
.CommandText = prmSQL
.Connection = conn
.ExecuteNonQuery()
End With
ExecuteSQL = True
End Function
Public Function ExcuteReader(ByVal prmSQL As String) As OleDbDataReader
Dim dr As OleDbDataReader
Dim comm As New OleDbCommand
connectData()
With comm
.CommandType = CommandType.Text
.CommandText = prmSQL
.Connection = conn
dr = .ExecuteReader()
Return dr
End With
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dr As OleDbDataReader
Dim code As String = BS.Text
Dim s As String = "select * from TGsc where ID_C ='" & code & "' "
dr = ExcuteReader(s)
dr.Read()
LN.Text = dr.Item("Aria").ToString
SN.Text = dr.Item("Server").ToString
End Sub
Public conn As OleDbConnection
Public Sub connectData() Handles MyBase.Load
Dim connectionString As String = "Provider=Microsoft.ace.OLEDB.12.0;Data Source=.\\twdb.accdb;"
conn = New OleDbConnection(connectionString)
If conn.State = ConnectionState.Closed Then conn.Open()
End Sub
Date :
2013-05-13 20:19:37
By :
mr.win
No. 3
Guest
ช่วยดูส่วนนี้ทีนะครับ
Dim code As String = BS.Text // รับข้อมูลจาก textbox เก็บไว้ในตัวแปร code
Dim s As String = "select * from TGsc where ID_C ='" & code & "' " //สั่งให้เลือกข้อมูลที่ตรงกับตัวแปร code