اذهب الي المحتوي
أوفيسنا

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


User user

الردود الموصى بها

لدى 10 جداول محتاج انشائهم بالكود فى قاعدة بيانات خارجيه 
وكل جداول له بيانات مختلفة 
Dim strSQL3 As String
Dim B As New Access.Application
Set B = CreateObject("Access.Application")
B.OpenCurrentDatabase "D:\New folder (2)\Database.accdb"
strSQL1 = "CREATE TABLE asrt_tbl " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
B.DoCmd.RunSQL strSQL3
هذا الكود لانشاء جدول واحد 

تم تعديل بواسطه User user
رابط هذا التعليق
شارك

تفضل مع ملاحظة التكرار في استعلام الانشاء .....

Dim strSQL3, strSQL1, strSQL2 As String
Dim B As New Access.Application
Set B = CreateObject("Access.Application")
B.OpenCurrentDatabase "D:\New folder (2)\Database.accdb"
strSQL1 = "CREATE TABLE asrt_tbl " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL2 = "CREATE TABLE asrt_tbl1 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL3 = "CREATE TABLE asrt_tbl2 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
B.DoCmd.RunSQL strSQL1
B.DoCmd.RunSQL strSQL2
B.DoCmd.RunSQL strSQL3

 

رابط هذا التعليق
شارك

37 دقائق مضت, ناقل said:

تفضل مع ملاحظة التكرار في استعلام الانشاء .....

Dim strSQL3, strSQL1, strSQL2 As String
Dim B As New Access.Application
Set B = CreateObject("Access.Application")
B.OpenCurrentDatabase "D:\New folder (2)\Database.accdb"
strSQL1 = "CREATE TABLE asrt_tbl " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL2 = "CREATE TABLE asrt_tbl1 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL3 = "CREATE TABLE asrt_tbl2 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
B.DoCmd.RunSQL strSQL1
B.DoCmd.RunSQL strSQL2
B.DoCmd.RunSQL strSQL3

 

بينفذ اول امر فقط 

Capture26.JPG

Capture27.JPG

تم تعديل بواسطه User user
رابط هذا التعليق
شارك

40 دقائق مضت, User user said:

بينفذ اول امر فقط 

Capture26.JPG

Capture27.JPG

الان مجرب الكود ويعمل .... انظر الجداول الثلاث تم انشاؤها ....

Dim strSQL3, strSQL1, strSQL2 As String
Dim B As New Access.Application
Set B = CreateObject("Access.Application")
B.OpenCurrentDatabase "D:\Database.accdb"
strSQL1 = "CREATE TABLE asrt_tbl " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL2 = "CREATE TABLE asrt_tbl1 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL3 = "CREATE TABLE asrt_tbl2 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
B.DoCmd.RunSQL strSQL1
B.DoCmd.RunSQL strSQL2
B.DoCmd.RunSQL strSQL3
    B.CloseCurrentDatabase
Set B = Nothing
    B.Quit

 

1.png

رابط هذا التعليق
شارك

من فضلك ممكن المثال 

7 دقائق مضت, ناقل said:

الان مجرب الكود ويعمل .... انظر الجداول الثلاث تم انشاؤها ....

Dim strSQL3, strSQL1, strSQL2 As String
Dim B As New Access.Application
Set B = CreateObject("Access.Application")
B.OpenCurrentDatabase "D:\Database.accdb"
strSQL1 = "CREATE TABLE asrt_tbl " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL2 = "CREATE TABLE asrt_tbl1 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL3 = "CREATE TABLE asrt_tbl2 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
B.DoCmd.RunSQL strSQL1
B.DoCmd.RunSQL strSQL2
B.DoCmd.RunSQL strSQL3
    B.CloseCurrentDatabase
Set B = Nothing
    B.Quit

 

1.png

تم تعديل بواسطه User user
رابط هذا التعليق
شارك

في ٢٢‏/١١‏/٢٠٢١ at 15:03, ناقل said:

تفضل .....

 

moh.rar 663.46 kB · 27 downloads

وهذا الفلدر به القاعدة المنشأ فيها الجداول .... ضع الفولدر في الدرايف D

 

New folder (2).rar 657.44 kB · 26 downloads

لو جدول من الجداول المكتوبه فى الكود موجودة فى قاعدة البيانات 
بتظهر الخطا ده 
ازاى نخليه يتجاهل الموجود بنفس الاسم ويضيف الباقى 

ta.JPG

رابط هذا التعليق
شارك

13 دقائق مضت, User user said:

يكمل عادى من غير مايحذف 
مثلا لو جدول asrt_tbl موجود يتجاهله ويكمل الباقى عادى 

جرب الشيفرة هذه .....

On Error Resume Next
Dim strSQL3, strSQL1, strSQL2 As String
Dim B As New Access.Application
Set B = CreateObject("Access.Application")
B.OpenCurrentDatabase "D:\New folder (2)\Database.accdb"
strSQL1 = "CREATE TABLE asrt_tbl " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL2 = "CREATE TABLE asrt_tbl1 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
strSQL3 = "CREATE TABLE asrt_tbl2 " _
            & "(Code INTEGER , cosmotic CHAR(50), available BIT , " _
            & "supplier CHAR(50),Unit CHAR(30), unitprice Double ,Quantity CHAR(30) , " _
            & "CONSTRAINT asrt_tblConstraint UNIQUE " _
            & "(Code, cosmotic, available, supplier, Unit, unitprice, Quantity ));"
B.DoCmd.RunSQL strSQL1
B.DoCmd.RunSQL strSQL2
B.DoCmd.RunSQL strSQL3
    B.CloseCurrentDatabase
Set B = Nothing
    B.Quit
MsgBox Space(20) & "تمت العملية بنجاح.." & Space(20), msgstyle, "للمعلومية"

 

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • المتواجدين الان   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information