Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
VB
gridview.datasource=ds.tables(0)/(1)/...(6)
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.
Posted
Comments
Amol_27101982, India 15-Nov-11 0:01am    
Have you got any solution or not ??
Jαved 28-Nov-11 1:27am    
not yet.

1 solution

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.

VB
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()

Hope this will help you

~Amol
 
Share this answer
 
v2
Comments
Jαved 28-Nov-11 1:33am    
no Amol i can run query on table. but i am asking about running query which is added later in the Access Database.

ex. my query name is query1 in database then
how do i run query1 using .net.

i write
Dim selectCMD As SqlCommand = New SqlCommand("SELECT CustomerID, CompanyName FROM query1", nwindConn)

selectCMD.ExecuteNonQuery()
Dim custDS As DataSet = New DataSet
custDA.Fill(custDS, "Query1")

can i run in access?

because i can run using SQLserver query perfectly

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900