30-01-23, 01:15 PM
(28-01-23, 11:36 PM)aljzazy كتب :كود :
Dim command As New SqlCommand("INSERT INTO table_name (image_column) VALUES (@image)", connection)
command.Parameters.AddWithValue("@image", DBNull.Value)
command.ExecuteNonQuery()
كود :
If PictureBox1.Image Is Nothing Then
Dim command As New SqlCommand("INSERT INTO table_name (image_column) VALUES (@image)", connection)
command.Parameters.AddWithValue("@image", DBNull.Value)
command.ExecuteNonQuery()
Else
' code to insert the image
End If
قمت بكتابة كود لكن يظهر خطا موضح في صوره
هدا كود
PHP كود :
If fullname.Text = "" Then
MessageBox.Show("الرجاء ادخال اسم العميل")
Exit Sub
End If
Dim sql = "select *from tbl_customers where cus_id=N'" & Val(customer_code.Text) & "'"
Dim adp As New SqlDataAdapter(sql, Module1.con)
Dim ds As New DataSet
adp.Fill(ds)
Dim dt = ds.Tables(0)
If dt.Rows.Count > 0 Then
MessageBox.Show("اسم عميل موجود مسبقا")
Else
Dim DR = dt.NewRow
DR!CUS_ID = customer_code.Text
DR!FullName = fullname.Text
DR!TEL = tel.Text
DR!Email = email.Text
DR!country = ComboBox1.Text
DR!city = ComboBox2.Text
DR!status = True
If PictureBox1.Image Is Nothing Then
Dim command As New SqlCommand("INSERT INTO tbl_customers (picture) VALUES (@image)", Module1.con)
command.Connection = Module1.con
command.Parameters.AddWithValue("@image", DBNull.Value)
command.ExecuteNonQuery()
Else
If ofd.FileName <> "" Then
Dim imgbytearray() As Byte
Dim stream As New MemoryStream
PictureBox1.Image.Save(stream, ImageFormat.Jpeg)
imgbytearray = stream.ToArray()
stream.Close()
DR!picture = imgbytearray
End If
dt.Rows.Add(DR)
Dim cmd As New SqlCommandBuilder(adp)
adp.Update(dt)
MessageBox.Show("تم حفظ بنجاح")
btn_close_Click(sender, e)
End If
End If
