Stored Procedures with Access and .NET?

Results 1 to 2 of 2

Thread: Stored Procedures with Access and .NET?

  1. #1
    Join Date
    Dec 1969

    Default Stored Procedures with Access and .NET?

    I just got VisualStudio.Net and although I&#039;m completely confused as to how to use it (or anything .NET for that matter), I did notice something unusual that seems kind of usefull... When I create a database connection to an Access 2000 database, VisualStudio.NET shows some of the Queries as either Stored Procedures or Views which I thought were not possible in Access (at least not without a lot of work.) <BR><BR>At the moment, I can&#039;t figure out how to do much in VS.NET, so I can&#039;t really test to see if these Queries are being treated as real Stored Procedures, or if this is just a glitch in VS.NET. That, and I&#039;m not sure why some of my queries are showing up as Views while others are showing up as Stored Procedures.<BR><BR>Has anyone tried using Access queries as Stored Procedures? Does it work?

  2. #2
    Join Date
    Dec 1969

    Default RE: Stored Procedures with Access and .NET?

    Hi,<BR><BR>If you have a query stored in you access database then it becomes the equivalent of a stored procedure (in that it is a query stored in the database and gets compiled).<BR><BR>You refer to it by name and can call it with parameters a la SQL stored procedures:<BR><BR><BR>Dim objConnection As OledbConnection<BR>Dim objCmd As OledbCommand<BR>Dim strConnection As String<BR><BR>strConnection = "CONNECTION STRING HERE"<BR><BR>&#039;Create and open connection object<BR>objConnection = New OledbConnection(strConnection)<BR>objConnection.Op en()<BR><BR>&#039;Create the command and set its properties<BR>objCmd = New OledbCommand()<BR>objCmd.Connection = objConnection<BR>objCmd.CommandText = "[NAME OF STORED PROCEDURE/QUERY]"<BR>objCmd.CommandType = CommandType.StoredProcedure<BR><BR>YOURDATAGRID.Da taSource = objCmd.ExecuteReader(CommandBehaviour.CloseConnect ion)<BR><BR>YOURDATAGRID.DataBind()<BR><BR>Woo Hoo<BR><BR>Good old big red wrox books<BR><BR>Dan<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts