RE: ADO.NET Issue

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



you can first using this class to retrive dataset to your code:
Imports System
Imports System.Data
Imports System.Data.SqlClient


Public Class SQL

Public Function OpenDataSet(ByVal ProcedureArgs As String) As DataSet
Try
Dim ConnectionString As String =
ConfigurationSettings.AppSettings("sqlSurvey")
Dim oConn As New SqlConnection(ConnectionString)
Dim oDA As SqlDataAdapter
OpenDataSet = New DataSet
oConn.Open()
oDA = New SqlDataAdapter(ProcedureArgs, oConn)
oDA.Fill(OpenDataSet, "Info")
oDA.Dispose()
oDA = Nothing
oConn.Close()
oConn = Nothing
Catch ex As SqlException
OpenDataSet.Tables.Remove("Info")
OpenDataSet.Tables.Add(ex.ToString)
End Try
End Function

Public Function UpdateInfo(ByVal ProcedureArgs As String) As String
Try
Dim ConnectionString As String =
ConfigurationSettings.AppSettings("sqlSurvey")
Dim oConn As New SqlConnection(ConnectionString)
Dim oCmd As New SqlCommand(ProcedureArgs, oConn)
oConn.Open()
oCmd.ExecuteNonQuery()
oCmd.Dispose()
oCmd = Nothing
oConn.Close()
oConn = Nothing
Return "Update Success"
Catch ex As SqlException

Return ex.ToString
End Try
End Function
Ebd Class


"HLong" wrote:

> I am trying to create a windows app with data access. I need to load few
> tables on a dataset when the app loads. I now I need a dataset, dataadapter,
> and connection obj. I would like to know which is the best way to go about
> loading the tables onto the dataset. My plan was to create a global dataset
> and a sub to be called at load that would create a dataadapter, a command obj
> and array of the sql statements for each table. Loop thru the array to set
> the commandtext, set the command obj to the dataadapter.selectcommand and
> fill the dataset with each table. I tryied this but is not working. Please
> can someone give me some help?
.



Relevant Pages