尝试从数据库中提取数据并将其显示在数据网格视图的表中。正在创建带有标题的表,但它不会填充值。一些代码被注释掉,因为我试图先处理 2 个表。非常感谢任何帮助,Visual Basic 的基本知识!
公共类 DriverOption
Public Sub btnStaff_Click(sender As System.Object, e As System.EventArgs) Handles btnStaff.Click
Dim objconnection As New OleDb.OleDbConnection("Provider=msdaora;Data Source=orabis;User Id=112221800;Password=112221800;")
Dim objinvoicesDA As New OleDb.OleDbDataAdapter("select * from CUSORDER, CUSORDER ", objconnection)
Dim objinvoicesCB As New OleDb.OleDbCommandBuilder(objinvoicesDA)
Dim objdataset As New DataSet()
Dim objordersdA As New OleDb.OleDbDataAdapter("select CUSORDER.ORDERID, CUSORDER.ORDERDATE, CUSORDER.STAFFID, CUSTOMER.CUSTOMERID, CUSTOMER.CUSTOMERADD_1 FROM CUSORDER,CUSTOMER WHERE CUSORDER.CUSTOMERID = CUSTOMER.CUSTOMERID", objconnection) 'orderdetails.unitprice from orders , orderdetails where orders.orderid = orderdetails.orderid", objconnection)
Dim objordersCB As New OleDb.OleDbCommandBuilder(objordersdA)
'Dim objcustomersDA As New OleDb.OleDbDataAdapter("select * from CUSTOMER", objconnection)
'Dim objcustomersCB As New OleDb.OleDbCommandBuilder(objcustomersDA)
'Dim objproductsDA As New OleDb.OleDbDataAdapter("select * from Products", objconnection)
'Dim objproductsCB As New OleDb.OleDbCommandBuilder(objproductsDA)
'Public Sub retrieve()
'objdataset.Clear()
'objproductsDA.FillSchema(objdataset, SchemaType.Source, "Products")
'objproductsDA.Fill(objdataset, "Products")
'objcustomersDA.FillSchema(objdataset, SchemaType.Source, "CUSTOMER")
'objcustomersDA.Fill(objdataset, "CUSTOMER")
objordersdA.FillSchema(objdataset, SchemaType.Source, "CUSTOMER")
objordersdA.Fill(objdataset, "CUSTOMER")
objordersdA.FillSchema(objdataset, SchemaType.Source, "CUSORDER")
objordersdA.Fill(objdataset, "CUSORDER")
'objinvoicesDA.FillSchema(objdataset, SchemaType.Source, "invoices")
'objinvoicesDA.Fill(objdataset, "invoices")
ViewDeliverys.DataGridView1.DataSource = objdataset.Tables("CUSORDER")