ADO Recordset Help

MTSkull

Well-known member
Joined
Mar 25, 2003
Messages
135
Location
Boulder, Colorado
Code:
        Dim adoConnection As New Connection
        Dim adoRecordset As New Recordset
        Dim spSource As Object
        Dim strConn As String

        strConn = "driver={SQL Server};server=" & gstrServer & ";database=" & gstrDB

        adoConnection.Open(strConn)

        adoRecordset.Open("EXEC SP_Telesales_Prof_Search " & txtProfID.Text & ", " & txtFirstName.Text & ", " & txtLastName.Text & "", adoConnection, CursorTypeEnum.adOpenStatic)

         grdResult.DataSource = adoRecordset

I am trying to run a stored procedure, which will return all of the professionals located in a field based on all or part entries in three fields. I tested the stored procedure and it works fine. When I try to run the code it breaks when I try to set the data grid to the result of the record set. Not sure if this will be enough to diagnose. I tried using a previous post as an example but I have not had much luck with SQL objects so I am trying ADO instead.

Brian
 
code that you provided works fine in VB6 (i pressume), but .Net
have different aproach for data storing,representing and so on .....
RecordSet DO NOT exist in .NET they are here JUST FOR compatibility!!!
 
Last edited by a moderator:
Datagrids expect the Datasource property to be .Net compatible source (DataSet, DataTable etc)

Recordsets are accessed via COM interop as a backwards compatible measure - not really intended to be used with the .Net controls.
 
I am starting to figure it out now. I am now trying to figure out how to get the results from the stored procedure into the datagrid. Can I do it directly or do I need a liason of sorts?
Brian
 
Code:
        Dim sqlAdapter As SqlClient.SqlDataAdapter
        Dim dsDataSet As DataSet
        Dim strConn As String
        Dim strSQL As String

        strConn = "data source=" & gstrServer & ";initial catalog=" & gstrDB & ";user id = sa"
        strSQL = "EXEC SP_Telesales_Prof_Search " & txtProfID.Text & ", " & txtFirstName.Text & ", " & txtLastName.Text & ""

        sqlAdapter = New SqlClient.SqlDataAdapter(strSQL, strConn)

        dsDataSet = New DataSet

        sqlAdapter.Fill(dsDataSet)

        grdResult.DataSource = dsDataSet

Thanks for the great link.

I dumped recordsets and am trying it with a dataset. How do I specify passthrough security instead of specifying a user name.

strConn = "data source=" & gstrServer & ";initial catalog=" & gstrDB & ";SPECIFY PASS THROUGH SECURITY HERE?"

I tried just removing it from the connection string but it just errors out.

Brian
 
Back
Top