اعتقد الحل بسيط يمكنك استخدام sql parameters مثال على ذلك
وفي زر الحفظ تضع الصب وتمرر له اسماء الاداوت
كود :
Public Sub Insert_Customer(ByVal Cus_ID As Int32, ByVal CusName As String, ByVal CusPhone As String, ByVal CusAddress As String)
Dim Cmd As New SqlCommand
With Cmd
.Connection = Con
.CommandType = CommandType.Text
.CommandText = "Insert Into Customer_Tbl ( Cus_ID,CusName,CusPhone,CusAddress)values(@Cus_ID,@CusName,@CusPhone,@CusAddress)"
.Parameters.Clear()
.Parameters.AddWithValue("@Cus_ID", SqlDbType.Int).Value = Cus_ID
.Parameters.AddWithValue("@CusName", SqlDbType.VarChar).Value = CusName
.Parameters.AddWithValue("@CusPhone", SqlDbType.VarChar).Value = CusPhone
.Parameters.AddWithValue("@CusAddress", SqlDbType.VarChar).Value = CusAddress
End With
If Con.State = 1 Then Con.Close()
Con.Open()
Cmd.ExecuteNonQuery()
Con.Close()
MsgBox("تم إضافة بيانات العميل بنجاح", MsgBoxStyle.Information, "حفظ")
Cmd = Nothing
End Subكود :
Insert_Customer_Tbl(Cus_ID.Text, CusName.Text, CusPhone.Text, CusAddress.Text)

