Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a query in access?

Status
Not open for further replies.

ZuperDuper

Programmer
Jun 4, 2004
39
US
I am trying to move vb6 app to .net and one of the rooutines require to create a query using existing mdb. I have vb6 code, and I need to know how to do same thing in vb.net. I create mdb and tables as ADOX;

The VB6 app right now is creating mdb, with couple tables, but it is using a workspace, and creates a query this way:

Public newws as workspace <this is created in separate module>

Dim NewQry As QueryDef

newdb = newws.OpenDatabase("c:\mydatabase.mdb")
newwsOpen = True
NewQry = newdb.CreateQueryDef("QUERY NAME", "SQL CODE HERE")


If query is not a good way to go, Maybe I can accomplish same thing by creating another table? What is a better thing to do? I am a novice programmer, so please keep that in mind :)
Well, thanks in advance.

You should never underestimate the predictability of stupidity.
 
You could reference the Access library, but to stick to purely managed code, you can do alot with DDL. For example, to create a simple query, you could send an sql statement with an OleDBCommand Object as follows:

Code:
"CREATE VIEW MyQuery AS SELECT * FROM TABLE1"
 
I am also trying to create queries within VB.Net. Could you expand on your previous answer please!

Regards,

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top