السلام عليكم
مرفق برنامجى للتعديل علية حيث ان عند الضغط على زر حفظ لا تتم اضافة البيانات من جريد فيو الى الجدول فى اكسس 2003
ارجو حل المشكلة
السلام عليكم
مرفق برنامجى للتعديل علية حيث ان عند الضغط على زر حفظ لا تتم اضافة البيانات من جريد فيو الى الجدول فى اكسس 2003
ارجو حل المشكلة
sayedaaa كتب:السلام عليكم
مرفق برنامجى للتعديل علية حيث ان عند الضغط على زر حفظ لا تتم اضافة البيانات من جريد فيو الى الجدول فى اكسس 2003
ارجو حل المشكلة
تاكد من وجود المعلومات في mdb الموجود في \debug\bin
شكرااا يا اخى المعلومات موجودة
والكود لا يحفظ بالقاعدة
sayedaaa كتب:شكرااا يا اخى المعلومات موجودة
والكود لا يحفظ بالقاعدة
insert into transaction (no_invoice,[number],name,unitprice,qty_out,total,Discount,GrandTotal)
عدل : number to [number] اضف : no_invoice
ثم اضف القيمة المناسبة ل no_invoice
تم تعديل هذه المشاركة بواسطة سمير ابراهيم في 14 نوفمبر 2011 في 16:13
أخى الاستاذ سمير اشكرك على مرورك الطيب
بس ما ظبط معى لو تكرمت عدل على المثال
sayedaaa كتب:أخى الاستاذ سمير اشكرك على مرورك الطيب
بس ما ظبط معى لو تكرمت عدل على المثال
Imports System.Data
Imports System.Data.OleDb
Public Class Form5
Dim conn As String ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\maydata.mdb" ' "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" & _
'Application.StartupPath & "\MayData.mdb"
Dim con As New OleDbConnection(conn)
Dim sqls As String = "select * from [transaction]" ' modify transaction to [transaction]
Dim dataset1 As New DataSet
Dim da As New OleDbDataAdapter(sqls, con)
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
con.Open()
Dim ole As New OleDbCommand
Dim i As Integer
For i = 0 To DataGridView1.Rows.Count - 2
Dim row As DataGridViewRow = DataGridView1.Rows(i)
Dim number As DataGridViewTextBoxCell = row.Cells(0)
Dim name As DataGridViewTextBoxCell = row.Cells(1)
Dim unitprice As DataGridViewTextBoxCell = row.Cells(2)
Dim qty_out As DataGridViewTextBoxCell = row.Cells(3)
Dim total As DataGridViewTextBoxCell = row.Cells(4)
Dim Discount As DataGridViewTextBoxCell = row.Cells(5)
Dim GrandTotal As DataGridViewTextBoxCell = row.Cells(6)
Dim Invoice_number As String = "1zQQ234" ' Change that to correct invoice_number
Dim sql As String = "insert into [transaction] (no_invoice,[number],name,unitprice,qty_out,total,Discount ,GrandTotal) VALUES " & _
"('" & Invoice_number & "','" & number.Value & "','" & name.Value & "'," & unitprice.Value & "," & qty_out.Value & "," & total.Value & "," & Discount.Value & "," & GrandTotal.Value & ")"
ole.Connection = con
ole.CommandText = sql
Dim x = ole.ExecuteNonQuery()
Next
MsgBox("تمت الاضافة")
da.Fill(dataset1, "transaction")
Button2.Enabled = False
DataGridView1.Rows.Clear()
Catch ex As Exception
MsgBox("لم تتم الاضافة")
Finally
con.Close()
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
DataGridView1.Rows.Clear()
Button2.Enabled = True
End Sub
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'MaydataDataSet.customer' table. You can move, or remove it, as needed.
Me.CustomerTableAdapter.Fill(Me.MaydataDataSet.customer)
'TODO: This line of code loads data into the 'MaydataDataSet.items' table. You can move, or remove it, as needed.
Me.ItemsTableAdapter.Fill(Me.MaydataDataSet.items)
End Sub
End Classما ظبط معى رغم انى نسخت الكود وعند الضغط على الزر لم تتم الاضافة
ارجو التعديل على المثال
sayedaaa كتب:ما ظبط معى رغم انى نسخت الكود وعند الضغط على الزر لم تتم الاضافة
ارجو التعديل على المثال
اعطيتك + 1 لانك علمتني ان كلمة transaction غير مقبولة في vb.net ولكنها مقبولة في داخل ال ACCESS ويجب تغييرها الى [transaction]
- remove the " " from da.Fill(dataset1, " transaction")
- include no_invoice in the INSERT
- change the field "number" to "[number]"
هذا هو المثال
تم تعديل هذه المشاركة بواسطة سمير ابراهيم في 15 نوفمبر 2011 في 14:13