منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : اكواد - (عرض اسماء الجداول في قاعدة ما - عرض اسماء الاعمدة في جدول ما)
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
اضف الادوات التالية:
Label1
ListBox1
ListBox2
DataGridView1
Button1


في منطقة التصريحات العامة اكتب:
رمز برمجي:

كود :
Dim str As String = ""
    Dim con As New OleDb.OleDbConnection
في حدث تحميل النموذج اكتب:
رمز برمجي:

كود :
Me.Text = My.Application.Info.ProductName
        If con.State = ConnectionState.Open Then
            con.Close()
        End If
في حدث النقر لزر الامر اكتب:
رمز برمجي:

كود :
If con.State = ConnectionState.Open Then
            con.Close()
        End If
        Dim dlg As New OpenFileDialog
        dlg.Filter = "Access 2007 db (*.accdb)|*.accdb| Access 2003 db (*.mdb)|*.mdb"
        If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
            If dlg.SafeFileName.EndsWith(".accdb") Then
                str = "provider=microsoft.ace.oledb.12.0;data source=" & dlg.FileName
            ElseIf dlg.SafeFileName.EndsWith(".mdb") Then
                str = "provider=microsoft.jet.oledb.4.0;data source=" & dlg.FileName

            End If
            con.ConnectionString = str
            Label1.Text = "Connected To: " & con.ConnectionString

        End If
        Dim SchemaTable As DataTable

        Try
            ListBox1.Items.Clear()
            If con.State = ConnectionState.Closed Then
                con.Open()
            End If
            SchemaTable = con.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, Nothing})
            Dim int As Integer
            For int = 0 To SchemaTable.Rows.Count - 1
                If SchemaTable.Rows(int)!TABLE_TYPE.ToString = "TABLE" Then
                    'Add items to list box
                    ListBox1.Items.Add(SchemaTable.Rows(int)!TABLE_NAME.ToString())
                End If
            Next

        Catch ex As Exception
            MsgBox(Err.Description, MsgBoxStyle.Critical, "")

        End Try
في حدث ListBox1_MouseClick
اكتب:
رمز برمجي:

كود :
Dim ds As New DataSet
        Dim da As New OleDb.OleDbDataAdapter("select * from " & ListBox1.Text & "", con)
        ds.Clear()
        DataGridView1.DataSource = Nothing
        da.Fill(ds, ListBox1.Text)
        DataGridView1.DataSource = ds
        DataGridView1.DataMember = ListBox1.Text


        ListBox2.Items.Clear()
        Dim dtable1 As DataTable
        dtable1 = con.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Columns, New Object() {Nothing, Nothing, ListBox1.Text, Nothing})

        For i = 0 To dtable1.Rows.Count - 1
            ListBox2.Items.Add(dtable1.Rows(i).Item(3).ToString)
        Next i
هل من الممكن عمل هكذا في الاصدار السادس
و كيف؟
شكرا .
(02-06-16, 12:45 PM)CLARO كتب : [ -> ]شكرا       .

اخي الكريم يوجد زر شكرا انقر عليه افضل من الاكتفاء بكلمة "شكرا"