السلام عليكم ورحمة الله وبركاته
لدي مشكلة بسيطة ولكن لا أعرف كيف أحلها
لدي برنامج تعامل مع قواعد بيانات اكسس
اضافه ، عرض ، بحث ، تعديل ، ....
عندما اقوم بالاضافه ومن ثم عمل عرض مباشرة تتكرر لدي سجلات البيانات ، اي يعرض السجل اكثر من مرا
مع انه في قاعدة البيانات الاصلية يوجد سجل واحد لهذا البيان
اتوقع ان المشكلة في الداتا ست لكن لا اعرف كيف احلها
هذا هو الكود
Dim SQLStatment As String
Dim RCount As Integer
Dim addInto As New OleDb.OleDbCommand
If TextBox1.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox9.Text = "" Or TextBox10.Text = "" Then
MsgBox("There are empty boxes must be completed ", MsgBoxStyle.Exclamation)
Exit Sub
End If
addInto.Connection = newConnection
addInto.CommandType = CommandType.Text
SQLStatment = "SELECT COUNT(*) FROM ph_database Where medicine_name='" & TextBox1.Text & "'"
addInto.CommandText = SQLStatment
newConnection.Open()
RCount = addInto.ExecuteScalar()
If RCount > 0 Then
MessageBox.Show("This Medicine already exists", "Add Medicine ", MessageBoxButtons.OK, MessageBoxIcon.Error)
newConnection.Close()
Exit Sub
End If
Try
addInto.CommandText = "INSERT INTO ph_database(medicine_number,medicine_name,Presentation,Main_Use,Manufacturer,Man_month,Man_year,Exp_month,Exp_year,Price,Quantity)" & _
"values ('" & TextBox2.Text & "','" & TextBox1.Text & "','" & ComboBox1.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & ComboBox2.Text & "','" & TextBox10.Text & "','" & ComboBox3.Text & "','" & TextBox9.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "') "
addInto.ExecuteNonQuery()
dataset1.Clear()
dataadapter1.Fill(dataset1, "ph_database")
newConnection.Close()
MsgBox("This medicine has been added to the system successfully", MsgBoxStyle.Information)
view.showlistnumber()
view.Show()
Me.Hide()
Catch ex As Exception
Exit Sub
End Try