Connection, dataadapter, dataset all set in code
I'm trying to set everything in code for this application. Here's the code so far:
Imports System.Configuration
Imports System.Collections.Specialized
Imports System.Data.SqlClient
Imports System.Threading
Module ModSubMain
Public cnnCushions As SqlConnection = New SqlConnection()
Sub Main()
Dim sAttr As String
sAttr = System.Configuration.ConfigurationSettings.AppSettings("ConnectionString")
cnnCushions.ConnectionString = sAttr
cnnCushions.Open()
'Dim sAll As NameValueCollection
'sAll = ConfigurationSettings.AppSettings()
Application.Run(New frmMain())
End Sub
End Module
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Hide()
Dim frm As Splash = New Splash()
frm.ShowDialog(Me)
Dim cmCushions As New SqlCommand("CusType", cnnCushions)
Dim daCushions As New SqlDataAdapter(cmCushions)
Dim dsCushions As New DataSet()
Dim drCushions As DataRow
'fill DataSet
daCushions.Fill(dsCushions, "Type") ******
'adding items with DataRow from DataSet
For Each drCushions In dsCushions.Tables("Type").Rows
cboType.Items.Add(drCushions("Type"))
Next
End Sub
I want to make the connection to the database in the module and the references to the dataadapter & dataset in the form. When I run through this code I receive an error on the line ending with ******
Error msg:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.
Can anyone tell me where I've gone wrong?
Thanks,
Corinne