تقييم الموضوع :
  • 1 أصوات - بمعدل 5
  • 1
  • 2
  • 3
  • 4
  • 5
[كود] @ اكواد مهمة @
#1
Information 
دي بعض الاكواد مهمه ولذيذه و هتساعد البعض 
للعمليات الاربعة واكثر 
( اضافة ،حفظ ، تعديل ، بحث ، حذف)
بالاضافة الى كود استدعاء الصور 

دعواتكم ليا  Heart

البحث بالرقم :

PHP كود :
Dim cn As New OleDbConnection

cn
.ConnectionString "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"

cn.Open()

Dim s As String

"select * from doctor where dr_jopno= " TextBox9.Text

Dim CmdReader 
As New OleDbCommand(scn)

Dim DeptReader As OleDbDataReader

DeptReader 
CmdReader.ExecuteReader

If DeptReader.Read() Then

TextBox1
.Text DeptReader("dr_name")

TextBox2.Text DeptReader("dr_address")

TextBox3.Text DeptReader("dr_qualification")

TextBox4.Text DeptReader("dr_specialization")

TextBox5.Text DeptReader("dr_jopno")

TextBox6.Text DeptReader("dr_dateof")

TextBox7.Text DeptReader("dr_telephone")

Else

MsgBox("الرقم غير موجود الرجاء التاكد من الرقم الصحيح"MsgBoxStyle.Information)

End If 

هذا كود  جديد ( افراغ  الحقول ) :
كود :
TextBox1.Text = ""

TextBox2.Text = ""

TextBox3.Text = ""

TextBox4.Text = ""

TextBox5.Text = ""

TextBox6.Text = ""

TextBox7.Text = ""

هذا الكود لفتح الصور بجميع الصيغ :

PHP كود :
OpenFileDialog1.Filter "images (*.jpg,*.jpeg,*.bmp,*.gif,*.png)|*.BMP;*.PNG;*.JPG;*.JPEG;*.GIF"

OpenFileDialog1.Title "open image "

OpenFileDialog1.ShowDialog()

If 
OpenFileDialog1.FileName Nothing Then Exit Sub 

هل يمكن أظهار رسالة في سطرين؟

نعم :
PHP كود :
MsgBox("hairan" vbCr "felnas")

or

MsgBox("any text here" vbNewLine "any text here"

كود خاص بالاضافة :

PHP كود :
Dim cn As New OleDbConnection

cn
.ConnectionString "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"

cn.Open()

Dim s As String

"insert into doctor values ('" TextBox1.Text "','" TextBox2.Text "','" TextBox3.Text "','" TextBox4.Text "'," TextBox5.Text ",'" TextBox6.Text "'," TextBox7.Text ")"

Dim CmdReader As New OleDbCommand(scn)

Dim res As Integer

res 
CmdReader.ExecuteNonQuery

MsgBox
("تمت إضافة سجل بنجاح"

كود خاص بالتعديل :
PHP كود :
Dim cn As New OleDbConnection

cn
.ConnectionString "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"

cn.Open()

Dim s As String

"update doctor set dr_name='" TextBox1.Text "',dr_address='" TextBox2.Text "',dr_qualification='" TextBox3.Text "',dr_specialization='" TextBox4.Text "',dr_dateof='" TextBox6.Text "',dr_telephone=" TextBox7.Text " where dr_jopno= " TextBox5.Text

Dim CmdReader 
As New OleDbCommand(scn)

Dim res As Integer

res 
CmdReader.ExecuteNonQuery

MsgBox
("تمت عملية التعديل بنجاح"


كود الحذف :
PHP كود :
Dim cn As New OleDbConnection

cn
.ConnectionString "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"

cn.Open()

Dim s As String

"delete from doctor where dr_jopno= " TextBox5.Text

Dim CmdReader 
As New OleDbCommand(scn)

Dim res As Integer

res 
CmdReader.ExecuteNonQuery

TextBox1
.Text ""

TextBox2.Text ""

TextBox3.Text ""

TextBox4.Text ""

TextBox5.Text ""

TextBox6.Text ""

TextBox7.Text ""

MsgBox("تمت عملية الحذف"

كود التحديث لقاعدة البيانات :

PHP كود :
Dim cn As New OleDbConnection

cn
.ConnectionString "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"

cn.Open()

Dim s As String

"select * from doctor "

Dim da As New OleDbDataAdapter(scn)

Dim ds As New DataSet

da
.Fill(ds"doctor")

DataGridView1.DataSource ds.Tables(0

كود التحميل :

PHP كود :
Dim cn As New OleDbConnection

cn
.ConnectionString "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dector.mdb"

cn.Open()

Dim s As String

"select * from doctor"

Dim CmdReader As New OleDbCommand(scn)

Dim DeptReader As OleDbDataReader

DeptReader 
CmdReader.ExecuteReader

DeptReader
.Read()

TextBox1.Text DeptReader("dr_name")

TextBox2.Text DeptReader("dr_address")

TextBox3.Text DeptReader("dr_qualification")

TextBox4.Text DeptReader("dr_specialization")

TextBox5.Text DeptReader("dr_jopno")

TextBox6.Text DeptReader("dr_dateof")

TextBox7.Text DeptReader("dr_telephone"

اذا كنت عاوز دخول البرنامج حسب الصلاحيات في قاعدة البيانات :
PHP كود :
If username.Text u.Text And password.Text p.Text Then

Form1
.Show()

Me.Hide()

Else

MsgBox("يوجد خطأ في إسم المستخدم أو كلمة المرور"MsgBoxStyle.Information"عذراً")

username.Clear()

password.Clear() 
دام الله لكم البشر والخير Heart
سبحان الله وبحمده Heart
الرد }}}
#2
شكراً جزيلاً
اسأل الله ان يجعلها في ميزان حسناتك
و تفريجاً لكل هم و غم
و تيسيراً من كل أمر عسير
آمين
الرد }}}
تم الشكر بواسطة: محبه البرمجه , sendbad100 , sendbad100 , asemshahen5
#3
(29-11-17, 09:07 PM)Amir_alzubidy كتب : شكراً جزيلاً
اسأل الله ان يجعلها في ميزان حسناتك
و تفريجاً لكل هم و غم
و تيسيراً من كل أمر عسير
آمين

شكرا يااستاذ امير ولك بالامثل
سبحان الله وبحمده Heart
الرد }}}
تم الشكر بواسطة: Amir_Alzubidy , sendbad100 , sendbad100 , asemshahen5


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم