简体   繁体   中英

Add parameter to dataAdapter.fill()

I am trying to add a parameter to a sqlDataAdapter. I have tried to use parameters.add() but the adapter is not a sqlCommand. Here is some of my code.

Private Sub convertToCSV(ByVal SqlQuery As String)
        Dim Dt As New DataTable()
        Dim SqlCon As New SqlConnection("Data Source=db;Initial Catalog=productionservicereminder;User Id=id;Password=pass;")
        Dim Ada As New SqlDataAdapter(SqlQuery, SqlCon)

        Ada.Fill(Dt)

  Public Sub excSP(ByVal ReprtID As Integer, ByVal pgid As Integer)

 convertToCSV(sql4)

End Sub

Basically I am trying to do something like this:

Ada.Parameters.Add(New SqlParameter("@pgid", pgid))

Use the SelectCommand:

ADA.SelectCommand.Parameters.Add(New SqlParameter("@pgid", pgid))

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.selectcommand.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM