如何以vb.net形式从Access运行查询 [英] how to run Query from Access in vb.net form

查看:72
本文介绍了如何以vb.net形式从Access运行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我正在开发一个应用程序,根据我的客户要求,我使用ms-access作为后端.我的数据库中有5个表,但要显示记录,我必须使用联接查询才能在datagridview中显示.

当我在访问中运行它时,它可以正常工作.但我不知道如何在.net表格Datagridview中运行它.

我尝试使用DataAdapter,Dataset和

Hello friends,

i am developing one application and as per my clients requirement i am using ms-access as backend. i have 5 tables in my database but to show records i had to use join query to show in datagridview.

when i run it in access it works properly. but i dont know how to run it in .net forms Datagridview.

i tried using DataAdapter, Dataset and used

gridview.datasource=ds.tables(0)/(1)/...(6)

,但是它不起作用.

我可以在Access中创建过程吗?

如何从vb.net形式的访问中执行查询?

请对此提供帮助.

but it doesn''t worked.

can i create procedure in access?
or
how to execute query from access in vb.net form?

please help me regarding this.

推荐答案

查询的复杂程度无关紧要,如果它在后台正确执行,则应通过.net运行.
只需在下面的命令对象中替换命令即可.

It doesn''t matter how complex your query is, if it is executing properly in the backed it should run through .net.
Just replace command in the bellow command object.

Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind")
Dim selectCMD As SqlCommand = New SqlCommand("SELECT CustomerID, CompanyName FROM Customers", nwindConn)
selectCMD.CommandTimeout = 30
Dim custDA As SqlDataAdapter = New SqlDataAdapter
custDA.SelectCommand = selectCMD
nwindConn.Open()
Dim custDS As DataSet = New DataSet
custDA.Fill(custDS, "Customers")
nwindConn.Close()

gridview.datasource = custDS 
custDS.DataBind()


希望对您有帮助

〜Amol


Hope this will help you

~Amol


这篇关于如何以vb.net形式从Access运行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆