Sheritlw
asked on
Send Parameters to Stored Query
I have a VB 2008 app with an access backend.
Within this access db, I have a large table.
I have made a stored query for this table to handle inserts and updates, now I need to know how to I reference this stored query and send in the parameters from the VB 2008 app.
Please provide sample code and no links. My IE crashes when I click on links.
Thank you
Within this access db, I have a large table.
I have made a stored query for this table to handle inserts and updates, now I need to know how to I reference this stored query and send in the parameters from the VB 2008 app.
Please provide sample code and no links. My IE crashes when I click on links.
Thank you
ASKER
I appreciate the example, but I've tried to convert to MS Access and they fail.
I really need an example for Access.
Thanks
I really need an example for Access.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Imports System
Imports System.Data
Imports System.Data.SqlClient
Class MainClass
Public Shared Sub Main()
Using con As New SqlConnection()
con.ConnectionString = "Data Source = .\sqlexpress;Database = Northwind; Integrated Security=SSPI"
con.Open()
Dim category As String = "Seafood"
Dim year As String = "1999"
' Create and configure a new command.
Using com As SqlCommand = con.CreateCommand()
com.CommandType = CommandType.StoredProcedur
com.CommandText = "SalesByCategory"
' Create a SqlParameter object for the category parameter.
com.Parameters.Add("@Categ
' Create a SqlParameter object for the year parameter.
com.Parameters.Add("@OrdYe
' Execute the command and process the results.
Using reader As IDataReader = com.ExecuteReader()
Console.WriteLine("Sales By Category ({0}).", year)
While reader.Read()
' Display the product details.
Console.WriteLine(" {0} = {1}", reader("ProductName"), reader("TotalPurchase"))
End While
End Using
End Using
End Using
End Sub
End Class
***My IE crashes when I click on links***... you might want to use firefox...