بسم الله الرحمن الرحيم
الاخوه الاعزاء
ارجو التكرم وشرح ما الخطا في هذا الكود لظهور هذا النص عند محاولة اضافة بيانات في ملف
وبارك الله فيكم
اخوكم
ابو عبيده
يبدو أن الخطأ موجود في Parameters.AddWithValue .. و مع الأسف لا يظهر هدا السطر .. حاول أن ترفق صورة أخرى
مقالاتي في VB.NET وبرامجي على موقعي الجديد :
ألسلام عليكم ورحمة الله وبركاته
الخوه الكرام هذا نص الكود ارجو المساعدة
اخوكم
ابو عبيده
Public Class Form1
Dim noteconn As New SqlClient.SqlConnection
Dim notecom As New SqlClient.SqlCommand
Dim notereader As SqlClient.SqlDataReader
Dim insertcommand As New SqlClient.SqlCommand
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
noteconn.ConnectionString = "server=MAIN\SQLEXPRESS;database=note;trusted_connection=true"
noteconn.Open()
notecom.Connection = noteconn
notecom.CommandType = CommandType.Text
notecom.CommandText = "select id,name,phone from information order by id;"
notereader = notecom.ExecuteReader
If notereader.Read Then
txtID.Text = notereader.Item("id")
txtName.Text = notereader.Item("name")
txtPhone.Text = notereader.Item("phone")
Else
MsgBox("Empty", MsgBoxStyle.Exclamation)
End If
notereader.Close()
noteconn.Close()
End Sub
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
noteconn.Open()
insertcommand.Connection = noteconn
insertcommand.CommandType = CommandType.Text
insertcommand.CommandText = "INSERT INTO Information(Name,Phone) VALUES(?,?)"
insertcommand.Parameters.Clear()
insertcommand.Parameters.AddWithValue("?", txtName.Text)
insertcommand.Parameters.AddWithValue("?", txtPhone.Text)
insertcommand.ExecuteNonQuery()
insertcommand.Dispose()
noteconn.Close()
MsgBox("ok", MsgBoxStyle.Information)
End Sub
استعمل زر "كود" لتحويط الكود في ردودك لتصبح أسهل في القراءة.
على العموم. جربها بهذه الطريقة
insertcommand.CommandText = "INSERT INTO Information(Name,Phone) VALUES(@Name,@Phone)"
insertcommand.Parameters.Clear()
insertcommand.Parameters.AddWithValue("@Name", txtName.Text)
insertcommand.Parameters.AddWithValue("@Phone", txtPhone.Text)بسم الله الرحمن الرحيم
الاخوه الاعزاء
بارك الله فيكم جميعا وجزاكم عنا وعنالمسلمين كل خير واخ كل من اهتم وساعد او حاول المساعده
فقد تم تصحيح الخطا
اخوكم
ابو عبيده
هذا الموضوع مغلق.
المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية
جارٍ التحقق من المتواجدين…