منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
data type mismatch in criteria expression access - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : data type mismatch in criteria expression access (/showthread.php?tid=47172)



data type mismatch in criteria expression access - um_noor20 - 03-10-23

السلام عليكم ورحمة الله وبركاته 


اخواني ممكن مساعدتي عند ادخال البيانات في الفورم واريد حفظها يظهر المسج التالي 

data type mismatch in criteria expression access

كيف من الممكن حل  هذه المشكله 

مع العلم اني قمت بمقارنة البيانات في قاعدة البيانات وفي الكود 


اتمنى مساعدتي 


مرفق البرنامج

https://www.mediafire.com/file/8zj84rv7fnpljjt/New_myproject2.rar/file


RE: data type mismatch in criteria expression access - um_noor20 - 04-10-23

من لديه الحل ارجو مساعدتي ولكم جزيل الشكر


RE: data type mismatch in criteria expression access - Taha Okla - 05-10-23

وعليكم السلام ورحمة الله وبركاته

المثال الذي طرحه الأخ (IYC)  مميز ومرتب،، 


ولكن إن كنت لا تحبين الربط بين الجداول ضمن قاعدة البيانات والاعتماد فقط على الأكواد في الادخال والربط :
فاستخدمي الكود التالي بدلاً من الكود الموجود في مثالك .. 
بنفس الطريقة التي طرحتها ولكن بشكل أبسط  وأسلس ..

كود :
       If MsgBox("هل تريد حفظ بيانات هذا السجل فعلا ؟", MessageBoxButtons.YesNo + MsgBoxStyle.DefaultButton2 + MessageBoxIcon.Question + MsgBoxStyle.MsgBoxRight, "حفظ البيانات") = vbNo Then Exit Sub

       ' التأكد من تعبئة كل الحقول
       If txtmynumber.Text = "" Then
           MsgBox("اكتب رقم المعاملة ", MessageBoxButtons.OK + MsgBoxStyle.DefaultButton1 + MessageBoxIcon.Exclamation + MsgBoxStyle.MsgBoxRight, "رقم المعاملة") : txtmynumber.Select() : Exit Sub
       ElseIf TextBox1.Text = "" Then
           MsgBox("اكتب الرقم الوظيفي ", MessageBoxButtons.OK + MsgBoxStyle.DefaultButton1 + MessageBoxIcon.Exclamation + MsgBoxStyle.MsgBoxRight, "الرقم الوظيفي") : TextBox1.Select() : Exit Sub
       ElseIf TextBox2.Text = "" Then
           MsgBox("اكتب اسم الموظف ", MessageBoxButtons.OK + MsgBoxStyle.DefaultButton1 + MessageBoxIcon.Exclamation + MsgBoxStyle.MsgBoxRight, "اسم الموظف") : TextBox2.Select() : Exit Sub
       ElseIf TextBox6.Text = "" Then
           MsgBox("اكتب نوع العطل ", MessageBoxButtons.OK + MsgBoxStyle.DefaultButton1 + MessageBoxIcon.Exclamation + MsgBoxStyle.MsgBoxRight, "نوع العطل ") : TextBox6.Select() : Exit Sub
       ElseIf TextBox4.Text = "" Then
           MsgBox("اكتب وصف العطل  ", MessageBoxButtons.OK + MsgBoxStyle.DefaultButton1 + MessageBoxIcon.Exclamation + MsgBoxStyle.MsgBoxRight, "اكتب وصف للعطل ") : TextBox4.Select() : Exit Sub
       ElseIf TextBox5.Text = "" Then
           MsgBox("اكتب تقرير الفني ", MessageBoxButtons.OK + MsgBoxStyle.DefaultButton1 + MessageBoxIcon.Exclamation + MsgBoxStyle.MsgBoxRight, "تقرير الفني  ") : TextBox5.Select() : Exit Sub
       ElseIf TextBox3.Text = "" Then
           MsgBox("اكتب تقرير المسؤل المباشر ", MessageBoxButtons.OK + MsgBoxStyle.DefaultButton1 + MessageBoxIcon.Exclamation + MsgBoxStyle.MsgBoxRight, "تقرير المسئول المباشر  ") : TextBox3.Select() : Exit Sub

       End If

       Dim CmdInsert As New OleDbCommand
       CmdInsert.Connection = Con

       '========================================================================
       Dim A1 As DateTime = DateTimePicker1.Text.Trim
       Dim A2 As String = cmpDepartment.Text.Trim
       Dim A3 As Int16 = TextBox1.Text.Trim
       Dim A4 As String = TextBox2.Text.Trim
       Dim A5 As Int16 = txtmynumber.Text.Trim
       Dim A6 As String = cmpSection.Text.Trim
       Dim A7 As String = TextBox6.Text.Trim
       Dim A8 As String = TextBox4.Text.Trim
       Dim A9 As String = TextBox5.Text.Trim
       Dim A10 As String = TextBox3.Text.Trim

       CmdInsert.CommandText = $" Insert Into maintanice (Damage_Date,
                                  MyDepertment, Emp_ID, Emp_Name, tNumber ,
                                  MySection, Damage_Type, Damage_Des,
                                  tecnical_Report, Headsection_Report  ) values
                               ( #{A1}# ,'{A2}',  {A3},  '{A4}', '{A5}' ,  
                                 '{A6}' ,'{A7}', '{A8}', '{A9}', '{A10}' ) "

       If Con.State = ConnectionState.Open Then Con.Close()
       Con.Open()
       CmdInsert.ExecuteNonQuery()
       Con.Close()
       '===================================================================
       MsgBox(" تم إضافة البيانات بنجاح ", MsgBoxStyle.Information, "إضافة")

       CmdInsert = Nothing

المتغيرات التي أفترضتها A1..A2 ...... إلخ
بإمكانك تغييرها لأسماء تناسب البيانات المخزنة فيها 
ولكن من أجل السرعة افترضت هذه الاسماء لها ...


RE: data type mismatch in criteria expression access - um_noor20 - 08-10-23

لك جزيل الشكر اخي Taha Okla على المساعدة تم الحل ولله الحمد كان الشرح جدا مميز وكافي