اخواني بعد اذنكم كيف يمكن ادخل عبارة strconnection التي بالفورم1 كيف يمكن اضيفها ادخلها في الموديل و املا الداتا غريد1 لانها تعطيني خطا بالاتصال.او تصحيح من فضلكم الاتصال بارك الله فيكم
الخطا بهاذي السطور
بارك الله في الجميع
كود :
Imports System.Data
Imports System.Data.OleDb
Module Module1
Public Con As New OleDbConnection
Public DtaSet As New DataSet()
Public OleDa As New OleDbDataAdapter()
Public Sub Data_Connection()
If Con.State = ConnectionState.Open Then Con.Close()
Try
Con = New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source=|datadirectory|\GALERY.mdb ")
Con.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "لم يتم الإتّصال", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
Con.Close()
End
End Try
End Sub
End Module
كود :
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
With Con
If .State <> ConnectionState.Open Then
.ConnectionString = StrConnection()
.Open()
With OleDa
.SelectCommand = New OleDbCommand()
.SelectCommand.CommandText = "SELECT * FROM Customers order by Serial_Number"
.SelectCommand.Connection = Con
Dim Ole As New OleDbCommandBuilder(OleDa)
DtaSet.Clear()
.Fill(DtaSet, "Table1")
End With
Catch ex As Exception
MsgBox(ex.Message(), MsgBoxStyle.Critical, "Error...")
Finally
Con.Close()
End Try
End Sub
End Class
كود :
With Con
If .State <> ConnectionState.Open Then
.ConnectionString = StrConnection()
.Open()