مشكلة مع زر اضافة سجل - الباشا شكر - 25-06-13
هذا هو السورس كود لحفظ سجل عندى والادوات الموجوده على الفورم
3 تيكست بوكس وريتش بوكس
إقتباس :If TextBox1.Text = vbNullString Then
MessageBox.Show("أنت لم تدخــــل الأســــــم", "تنبيـــه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)
PhoneFrm_Load(Nothing, Nothing)
Exit Sub
End If
Dim GetHim As New OleDbDataAdapter("Select * from tabel2 Where Nam='" & TextBox1.Text & "'", Cn)
Dim DS1 As New DataSet
DS1.Clear()
GetHim.Fill(DS1, "tabel2")
If DS1.Tables("tabel2").Rows.Count <> 0 Then
MessageBox.Show("موجـــــــود ســــــابقا", "تنبيـــــــه", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)
PhoneFrm_Load(Nothing, Nothing)
Exit Sub
End If
'======================================
Try
NewBtn.Enabled = False
BS.EndEdit()
DP.Update(DS, "tabel2")
DS.Clear()
DP.Fill(DS, "tabel2")
BS.MoveLast()
ShowRe()
MessageBox.Show("تمــــــت عمليـــــة الحـــــــفظ بنجـــــــاح", "حــــــفظ a.sh", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)
PhoneFrm_Load(Nothing, Nothing)
Catch ex As Exception
MessageBox.Show("العمليـــــة فشــــــــلت", "خـــــــطأ", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)
SaveBtn.Enabled = False
NewBtn.Enabled = True
End Try
ولكن تظهرلى مشكلة عند الاضافة
تظهرلى رسالة العملية فشلت فماهو الحل
مشكلة مع زر اضافة سجل - سعود - 25-06-13
فيه طريقة اسهل للحفظ
كود :
dim insertinto as new oledbcommand("insert into tb (name,age) values(@name,@age)",con)
insertinto.parameters.addwithvalue("@name",oledbtype.varchar).value=name.text
insertinto.parameters.addwithvalue("@age",oledbtype.int).value=age.text
كود :
con.open
try
insert into executenonquery
هنا رسالة تم الحفظ
Catch ex As Exception
هنا رسالة الخطا
end try
مشكلة مع زر اضافة سجل - الباشا شكر - 25-06-13
سعود كتب :فيه طريقة اسهل للحفظ
كود :
dim insertinto as new oledbcommand("insert into tb (name,age) values(@name,@age)",con)
insertinto.parameters.addwithvalue("@name",oledbtype.varchar).value=name.text
insertinto.parameters.addwithvalue("@age",oledbtype.int).value=age.text
كود :
con.open
try
insert into executenonquery
هنا رسالة تم الحفظ
Catch ex As Exception
هنا رسالة الخطا
end try
طب ممكن تعدلى الكود على ما موجود بالكود تبعى
مشكلة مع زر اضافة سجل - سعود - 25-06-13
إقتباس :طب ممكن تعدلى الكود على ما موجود بالكود تبعى
احذفه بشكل كامل وحط هذا بمكانه 
او ارفع مثال صغير بنفس الفكرة اعدل عليه.
مشكلة مع زر اضافة سجل - الباشا شكر - 26-06-13
سعود كتب :فيه طريقة اسهل للحفظ
كود :
dim insertinto as new oledbcommand("insert into tb (name,age) values(@name,@age)",con)
insertinto.parameters.addwithvalue("@name",oledbtype.varchar).value=name.text
insertinto.parameters.addwithvalue("@age",oledbtype.int).value=age.text
كود :
con.open
try
insert into executenonquery
هنا رسالة تم الحفظ
Catch ex As Exception
هنا رسالة الخطا
end try
استخدمت الكود وعدلت فيه لحد ماقدرت لكن بيأتى تعليم خطأ على الجملة الاتيه
insert into executenonquery
مشكلة مع زر اضافة سجل - سعود - 26-06-13
خطا معلش شوف انا كتبت تعريفه كذا
وطلبت تنفيذه كذا
كود :
insert into executenonquery
اجعله كذا
كود :
insertinto.executenonquery
مشكلة مع زر اضافة سجل - الباشا شكر - 26-06-13
سعود كتب :خطا معلش شوف انا كتبت تعريفه كذا
وطلبت تنفيذه كذا
كود :
insert into executenonquery
اجعله كذا
كود :
insertinto.executenonquery
اخى الحبيب هذا هو الكود الذى استخدمته ولم يظهر به اى اخطاء ولكنه عند التجربة تظهرلى رسالة عدم الحفظ
إقتباس : Dim insertinto As New OleDbCommand("insert into tabel2 (nam,price of buy,price of sell,notes) values(@name,@price of buy,@price of sell,@notes)", Cn)
insertinto.Parameters.AddWithValue("@nam", OleDbType.Integer).Value = TextBox1.Text
insertinto.Parameters.AddWithValue("@price of buy", OleDbType.Integer).Value = TextBox2.Text
insertinto.Parameters.AddWithValue("@price of sell", OleDbType.Integer).Value = TextBox3.Text
insertinto.Parameters.AddWithValue("@notes", OleDbType.Integer).Value = RichTextBox1.Text
Cn.Open()
Try
insertinto.ExecuteNonQuery()
MsgBox("تمت عملية الحفظ بنجاح,حفظ")
Catch ex As Exception
MsgBox("لم يتم الحفظ")
End Try
مشكلة مع زر اضافة سجل - سعود - 26-06-13
لا تكتب لم يتم الحفظ وانما اسند دالة الخطا
كود :
Msgbox (Err.Description)
مشكلة مع زر اضافة سجل - الباشا شكر - 26-06-13
سعود كتب :لا تكتب لم يتم الحفظ وانما اسند دالة الخطا
كود :
Msgbox (Err.Description)
قالى خطأ فى بناء جملة insert into
مشكلة مع زر اضافة سجل - Sajad - 26-06-13
السلام عليكم
ما جملة الخطأ اخي العزيز؟
|