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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing A Parameter To An Access Query 1

Status
Not open for further replies.

hitechboy78737

Programmer
Nov 8, 2004
82
US
How do you pass a parameter from vb.net to an access query?

I'm using this function, what should I add?

Code:
Function drFromQuery(ByVal objConn As System.Data.OleDb.OleDbConnection, ByVal strQuery As String)as oledbDataReader
        Dim objCommand As New OleDbCommand
        Dim objDataReader As OleDbDataReader
        objCommand.Connection = objConn
        objCommand.CommandText = strQuery
        objCommand.CommandType = CommandType.StoredProcedure
        Try
            objConn.Open()
            objDataReader = objCommand.ExecuteReader
            If objDataReader.Read = True Then
                Return objDataReader
            End If
        Catch ex As OleDbException
            MessageBox.Show(ex.Message, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Stop)
        Catch ex As Exception
            MessageBox.Show(ex.Message, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Stop)
        Finally
            objCommand.Dispose()
        End Try
End Function

Thanks bunches
Kevin Howell
Briefcase of Talent- Austin,Texas
 
Try having a look at the help files (or msdn if you do not have them) for Parameters.Add - there should be everything you need there.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top