تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] استفسار
#3
(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(sqlModule1.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(streamImageFormat.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(sendere)
 
           End If

 
       End If 


الملفات المرفقة صورة/صور
   
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
استفسار - بواسطة ali_ahmed12 - 27-01-23, 08:22 PM
RE: استفسار - بواسطة aljzazy - 28-01-23, 11:36 PM
RE: استفسار - بواسطة ali_ahmed12 - 30-01-23, 01:15 PM
RE: استفسار - بواسطة Jounior_P - 30-01-23, 02:56 PM
RE: استفسار - بواسطة AnyDesk - 01-02-23, 05:49 PM


التنقل السريع :


يقوم بقرائة الموضوع: