查看: 1767|回复: 10
|
Ms Access和vb.net的问题
[复制链接]
|
|
我有个问题就是我access里有3个table...然后我要在vb里将它们join在一起...
这是我的database....
customer----customerID,Firstname,Lastname,ContractNo,Address
product----ProductID,Flowername,Quantity,Cost
purchase----PurchaseID,CustomerID,ProductID,Quantity,Price
这段是我的code...
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\Desktop\FlowerShop.mdb"
con.Open()
sql = "SELECT * FROM Customer INNER JOIN Purchase ON Purchase.PurchaseID = Product.ProductID"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "FlowerShop")
con.Close()
MaxRows = ds.Tables("FlowerShop").Rows.Count
inc = -1
p.s(小弟还是在初学阶段...有什么不对尽量shoot)谢谢前辈们 |
|
|
|
|
|
|
|
发表于 4-11-2010 04:19 PM
|
显示全部楼层
SELECT purchase.PurchaseID, purchase.CustomerID, customer.FirstName, customer.Lastname, purchase.ProductID, product.Flowername, purchase.Quantity, purchase.Price
FROM product
INNER JOIN(customer INNER JOIN purchase ON purchase.CustomerID = customer.CustomerID) ON
purchase.ProductID = product.ProductID |
|
|
|
|
|
|
|

楼主 |
发表于 4-11-2010 04:35 PM
|
显示全部楼层
回复 2# Reader
哇老...原来是这样长的....
写进vb里的话嘛长长....
anywhere谢谢你...
有问题再请教你可以吗?? |
|
|
|
|
|
|
|

楼主 |
发表于 4-11-2010 06:21 PM
|
显示全部楼层
回复 2# Reader
sql = "SELECT purchase.PurchaseID, purchase.CustomerID, customer.FirstName, customer.Lastname, purchase.ProductID, product.Flowername, purchase.Quantity, purchase.Price FROM(product) INNER JOIN(customer INNER JOIN purchase ON purchase.CustomerID = customer.CustomerID) ON purchase.ProductID = product.ProductID"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "FlowerShop")
con.Close()
可是这句da.Fill(ds, "FlowerShop")
出现No value given for one or more required parameters的error... |
|
|
|
|
|
|
|
发表于 4-11-2010 06:27 PM
|
显示全部楼层
回复 Reader
哇老...原来是这样长的....
写进vb里的话嘛长长....
anywhere谢谢你...
...
未确认生物 发表于 4-11-2010 04:35 PM 
你是学生吧?你可以build query然后在VB.net Call。那样你就不用把query放在VB.net里。
我好久没用VB.net了。我通常用C#。尽量吧。。。 |
|
|
|
|
|
|
|
发表于 4-11-2010 06:46 PM
|
显示全部楼层
please make sure the table and the column name are spell correctly according to your DB |
|
|
|
|
|
|
|
发表于 4-11-2010 06:47 PM
|
显示全部楼层
please make sure the table and the column name are spell correctly according to your DB |
|
|
|
|
|
|
|

楼主 |
发表于 5-11-2010 04:45 PM
|
显示全部楼层
回复 7# Reader
还是一样的error
对的我还是学生...
不过却遇人不熟遇到不会教书的教师
zzz |
|
|
|
|
|
|
|
发表于 5-11-2010 08:47 PM
|
显示全部楼层
回复 5# Reader
你的 Query 放在 VB.net 里是指什么? strongly typed dataset? |
|
|
|
|
|
|
|
发表于 5-11-2010 11:57 PM
|
显示全部楼层
本帖最后由 Reader 于 6-11-2010 12:02 AM 编辑
回复 9# 宅男-兜着走
It means he don't need to put in such a long SQL command into the VB.net code. |
|
|
|
|
|
|
|
发表于 5-11-2010 11:59 PM
|
显示全部楼层
回复 8# 未确认生物
Hmm.....the Error message normally means that your column or table name are not spell correctly, Is there any way to download the DB and the code so that I can check it on my side? |
|
|
|
|
|
|
| |
本周最热论坛帖子
|