20-12-23, 02:28 AM
(19-12-23, 10:51 PM)Taha Okla كتب : وعليكم السلام ورحمة الله وبركاته
أرفق الأكواد المستخدمة حتى يتم تحليل الكود ومعرفة أين المشكلة..
كود :
Dim dt_products2 As New DataTable
Dim da As New OleDbDataAdapter
dt_products2.Clear()
da = New OleDbDataAdapter("select pro_code from products where pro_code = '" & pro_code.Text & "' ", con)
'da.Fill(dt_products2)
'If con.State = 1 Then con.Close()
'con.Open()
If pro_code.Text = "" Then
Exit Sub
End If
If da.Fill(dt_products2) = 0 Then
'For i = 0 To dt_products.Rows.Count - 1
MsgBox("لا يوجد هذا الصنف")
Else
'If i <> pro_code.Text Then
Dim cmd As New OleDbCommand
With cmd
.Connection = con
If con.State = 1 Then con.Close()
con.Open()
.CommandType = CommandType.Text
.CommandText = "select pro_code,pro_name,pro_sheraa from products where pro_code= @pro_code"
.Parameters.AddWithValue("@pro_code", OleDbType.VarChar).Value = pro_code.Text
Dim dr As OleDbDataReader = cmd.ExecuteReader
'If con.State = 1 Then con.Close()
'con.Open)
'While dr.Read
dr.Read()
pro_name.Text = dr.Item(1)
pro_price.Text = dr.Item(2)
dr.Close()
'End While
End With
'pro_code.Text = ""
End If
'con.Close()
'pro_code.Text = ""
con.Close()
