Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · ASP.NET Newsletter Application · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : ASP : ADO/ODBC : How can I execute a Stored Query using C# Signup · Login
Author Thread
How can I execute a Stored Query using C#
Posted in tutorial: Running Stored Queries in Access Database
·  Brandon
User
Joined: 21 Sep 2005
Total Posts: 1

How can I execute a Stored Query using C#

Posted: 21 Sep 2005
I am learning to program using C# . I'm using windows forms. How would I execute a stored query named "DuplicateQuery" using c# and windows forms?
·  MetalKid
User
Joined: 18 Mar 2006
Total Posts: 1
Answer
Posted: 18 Mar 2006
This is the answer in VB.NET. You should be able to convert it to C# easily.

Dim cmd As New OleDbCommand("DuplicateQuery")
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = New OleDbConnection("Your Connection String")

'If you have any parameters in the query, you set them up like this
cmd.Parameters.Add("@Variable", OleDbType.VarChar).Value = DBNull.Value 'or the actul value

Dim ds As New DataSet
Dim da As New OleDbDataAdapter(cmd)
da.Fill(ds)
Want to leave a comment? Login or Register for free!

Users Who Have Visited This Thread In Last 24 Hours
6 Visitors

Login to post a comment or start a new thread
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2010 Stardeveloper.com, All Rights Reserved.