منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
حل مشكلة هذا الكود - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : حل مشكلة هذا الكود (/showthread.php?tid=27600)



حل مشكلة هذا الكود - imam_boune - 23-11-18

مرحبا بالاساتذة  
لدي مشكلة في كود الاضافة

هذا الكود يقوم بالاضافة الى قاعدة البيانات من نوع اكسس
ارجو ممن لديه القدرة مساعدتي في حل هذه المشكلة

=================================================
==================================================

Public Sub InsertNewRowIn_info(ByVal Lblid As Long,ByVal Txtnom As String,ByVal Txttel As String,ByVal Txtwhats As String,ByVal Txtemail As String,ByVal Txtnotes As String)
Dim CmdInsert As New OleDbCommand
With CmdInsert
.Connection = Con
.CommandType = CommandType.Text
.CommandText = "Insert Into info (id , nom , tel , whats , email , notes)values( @id ,  @nom ,  @tel ,  @whats ,  @email ,  @notes)
.Parameters.Clear()
.Parameters.AddWithValue("@id", OleDbType.Integer).Value = Lblid
.Parameters.AddWithValue("@nom", OleDbType.VarChar).Value = Txtnom
.Parameters.AddWithValue("@tel", OleDbType.VarChar).Value = Txttel
.Parameters.AddWithValue("@whats", OleDbType.VarChar).Value = Txtwhats
.Parameters.AddWithValue("@email", OleDbType.VarChar).Value = Txtemail
.Parameters.AddWithValue("@notes", OleDbType.VarChar).Value = Txtnotes
End With
If Con.State = 1 Then Con.Close()
Con.Open()
CmdInsert.ExecuteNonQuery()
Con.Close()
MsgBox("تم إضافة السجل بنجاح", MsgBoxStyle.Information, "حفظ")
CmdInsert = Nothing
End Sub


RE: حل مشكلة هذا الكود - asemshahen5 - 23-11-18

كود :
   Public Sub InsertNewRowIn_info(Lblid As Integer, Txtnom As String, Txttel As String, Txtwhats As String, Txtemail As String, Txtnotes As String)
       Dim CmdInsert As New OleDb.OleDbCommand
       With CmdInsert
           .Connection = Con
           .CommandType = CommandType.Text
           .CommandText = "Insert Into info (id , nom , tel , whats , email , notes)values( @id ,  @nom ,  @tel ,  @whats ,  @email ,  @notes)"
           .Parameters.Clear()
           .Parameters.AddWithValue("@id", OleDbType.Integer).Value = Lblid
           .Parameters.AddWithValue("@nom", OleDbType.VarChar).Value = Txtnom
           .Parameters.AddWithValue("@tel", OleDbType.VarChar).Value = Txttel
           .Parameters.AddWithValue("@whats", OleDbType.VarChar).Value = Txtwhats
           .Parameters.AddWithValue("@email", OleDbType.VarChar).Value = Txtemail
           .Parameters.AddWithValue("@notes", OleDbType.VarChar).Value = Txtnotes
       End With
       If con.State = ConnectionState.Closed Then con.Open()
       CmdInsert.ExecuteNonQuery()
       MsgBox("تم إضافة السجل بنجاح", MsgBoxStyle.Information, "حفظ")
       CmdInsert = Nothing
   End Sub

كود :
   Public Sub InsertNewRowIn_info(Lblid As Integer, Txtnom As String, Txttel As String, Txtwhats As String, Txtemail As String, Txtnotes As String)
       Dim CmdInsert As New OleDb.OleDbCommand
       With CmdInsert
           .Connection = con
           .CommandType = CommandType.Text
           .CommandText = "INSERT INTO info (id,nom,tel,whats,email,notes)VALUES(" & Lblid & ",'" & Txtnom & "','" & Txttel & "','" & Txtwhats & "','" & Txtemail & "','" & Txtnotes & "')"
       End With
       If con.State = ConnectionState.Closed Then con.Open()
       CmdInsert.ExecuteNonQuery()
       MsgBox("تم إضافة السجل بنجاح", MsgBoxStyle.Information, "حفظ")
       CmdInsert = Nothing
   End Sub



RE: حل مشكلة هذا الكود - imam_boune - 23-11-18

شكرا يا استاذ asemshahen5

تم حل المشكلة

جزاك الله خيرا