Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim connectionStr As String = "Provider = Microsoft.Ace.OleDb.12.0;" & "Data Source = D:\My Project\BB Apartment VB\BB Apartment.accdb;"
Dim conn As New OleDbConnection(connectionStr)
conn.Open() 'มัน error ตรง conn นี้หร่ะคับ
Dim sql As String = "select * from UserEmployee"
Dim cmd As New OleDbCommand(sql, conn)
Dim reader As OleDbDataReader = cmd.ExecuteReader
Dim name As String
name = reader("UserID")
ListBox1.Items.Add(name)
conn.Close()
End Sub
'คือผมเป็นมือใหม่อ่ะคับ...งง มาก ตอนเรียนมันติดต่อได้ แต่พอมาทำตอนนี้ มันไม่ได้แร้ว งง ช่วยผมด้วยคับ ขอบคุณล่วงหน้าคับผม
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
Step into: Stepping over non-user code 'System.Data.OleDb.OleDbConnection.Open'
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
Dim strConn As String
Dim Conn As New OleDbConnection
' Code ติดต่อกับฐานข้อมูล Accress 2007
strConn = "provider=Microsoft.Jet.oleDb.4.0;" & _
"Data Source=..\\Computer_CheckcoseEmployees.mdb"
Dim Conn As New OleDbConnection(strConn)
Conn.Open()
ลองดู แล้วเอา database ไปไว้ใน bin ของโฟร์เดอร์ โปรแกรมที่เราเขียนด้วยนะ
มันขึ้นว่าCould not find installable ISAM. จะแก้ยังไงดีค่ะ
Date :
2011-07-13 00:16:10
By :
memorywhite
No. 25
Guest
Could not find installable ISAM.
แก้ยังไงดีคค่ะ
Code (VB.NET)
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim strConn As String
Dim Conn As New OleDb.OleDbConnection
Dim da As OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim dr As DataRow
Dim CurrentStorage As Integer
Dim IsFind As Boolean = False
'ฟอร์มโหลด
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
strConn = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:\Project.mdb"
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
ClearAllData()
ShowAllStorage()
FormatAllStorage()
End Sub
แต่มันขึ้น error ว่า Property access must assign to the property or use its value มันผิดตรงไหนค่ะ
โค้ดนี้นะค่ะ
Code (VB.NET)
Option Explicit On
Option Strict On
Imports System.Text
Imports System.Data
Imports System.Data.SqlClient
Public Class FormEquipment
Dim Conn As SqlConnection
Dim com As New SqlCommand()
Dim dr As SqlDataReader
Dim tr As SqlTransaction
Dim sb As New StringBuilder()
Private Sub ShowData()
sb.Remove(0, sb.Length)
sb.Append("SELECT ID,Name,Number")
sb.Append(" FROM Customer")
sb.Append(" ORDER BY CustomerID")
Dim sqlequipment As String = sb.ToString()
Dim dr As SqlDataReader
Dim dt As DataTable
com = New SqlCommand()
With com
.CommandType = CommandType.Text
.CommandText = sqlequipment
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dt = New DataTable()
dt.Load(dr)
dgvequipmentList.DataSource = dt
Else
dgvequipmentList.DataSource = Nothing
End If
End With
dr.Close()
End Sub
Private Sub FormEquipment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'VVDataSet.ChackEquipment' table. You can move, or remove it, as needed.
Me.ChackEquipmentTableAdapter.Fill(Me.VVDataSet.ChackEquipment)
Dim strConn As String
strConn = "Data Source=BLOG-8R3Q8PQKGG\SQLEXPRESS;Initial Catalog=VV;Integrated Security=True"
Conn = New SqlConnection(strConn)
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
ShowData()
dgvequipmentList() >>>ขึ้น error ว่า Property access must assign to the property or use its value ที่บรรทัดนี้ค่ะ <<<
End Sub