MTSkull Posted June 11, 2003 Posted June 11, 2003 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 Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
sizer Posted June 11, 2003 Posted June 11, 2003 what version of VB do you use VB.Net or VB6? Quote Some people are wise and some are other-wise.
MTSkull Posted June 11, 2003 Author Posted June 11, 2003 .net 2003 Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
sizer Posted June 11, 2003 Posted June 11, 2003 (edited) 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!!! Edited June 11, 2003 by sizer Quote Some people are wise and some are other-wise.
Administrators PlausiblyDamp Posted June 11, 2003 Administrators Posted June 11, 2003 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MTSkull Posted June 11, 2003 Author Posted June 11, 2003 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 Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
*Experts* jfackler Posted June 11, 2003 *Experts* Posted June 11, 2003 Abandon the recordset, concept as well as object. Read the link below and write some code. Post back here snippets of code that are giving you grief or with questions you have about ADO.net functionality. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Dndotnet/html/Usingadonet.asp Jon Quote
MTSkull Posted June 11, 2003 Author Posted June 11, 2003 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 Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
MTSkull Posted June 11, 2003 Author Posted June 11, 2003 Found it... Replace the user id = sa with Integrated Security=SSPI and it works... Wow that is cool. Brian Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.