HighTechTalks DotNet Forums  

MS Access Query - use like stored procedure?

Dotnet FAQs microsoft.public.dotnet.faqs


Discuss MS Access Query - use like stored procedure? in the Dotnet FAQs forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Brenda Pasquarello
 
Posts: n/a

Default MS Access Query - use like stored procedure? - 03-07-2006 , 12:51 PM






If connecting to MS Access DB instead of SQL, can you call a query similar
to how you would call an SQL Stored Procedure?

Examples would be great!



Reply With Quote
  #2  
Old   
Michael Bohman
 
Posts: n/a

Default Re: MS Access Query - use like stored procedure? - 03-08-2006 , 07:46 AM






Brenda Pasquarello skrev:
Quote:
If connecting to MS Access DB instead of SQL, can you call a query similar
to how you would call an SQL Stored Procedure?

Examples would be great!


Of course

1. Create a stored procedure in access (create a new question, use SQL
button and create you're question example 'SELECT * FROM MyTable' or if
you wan't to assign values 'SELECT * FROM MyTable WHERE ID=[@ID]')

2.Use the following code in you're *.cs or *.vb form
....
objCmd = new OleDbCommand ("Name of you're sp in access",objConn);
objCmd.CommandType = CommandType.StoredProcedure;
// OBSERV THAT THE ORDER BETWENN THE FORM AND SP MUST BE SAME
objCmd.Parameters.Add("@ID",((TextBox)e.Item.FindC ontrol("txtAdress")).Text);
// OPEN THE DATABASE...
objConn.Open();
objCmd.ExecuteNonQuery();
objConn.Close();

God luck, Michael


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.