|
-
Aug 29th, 2003, 10:15 AM
#1
Thread Starter
Lively Member
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
-
Aug 29th, 2003, 10:22 AM
#2
You have "CusType" as your SQL statement, which is not valid. If that is a stored procedure name then try setting the SQLCommand.CommandType to stored procedure before using it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|