|
-
Jun 17th, 2004, 08:42 AM
#1
Thread Starter
Lively Member
Database Error
Can Anyone help me with this problem. I have been trying to connect my vb.net project to a sql database for two weeks. Thanks
Option Explicit On
Imports System.data.sqlclient
Imports System.Data
Public Class frmMain
Inherits System.Windows.Forms.Form
Dim cn As New SqlConnection
Dim mycommand As New SqlCommand
Dim myDS As DataSet = New DataSet
Dim Mydatagrid As New DataGrid
Dim da As New SqlDataAdapter
Dim cmdtext As String = "select itemnumber from auto"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn.ConnectionString = "integrated security=true;initial catalog=justin"
'cn.Open() ****this gave me an error so I commented it out****
Dim cmdtext As String = "select * from [auto]"
Dim da As New SqlDataAdapter
da.SelectCommand = New SqlCommand(cmdtext, cn)
Dim dt As New DataTable("Table Auto")
da.Fill(dt)*****this is highlighted green and says:an unhandled exception of type "system.data.sqlclient.sqlexeption' occured in system.data.dll**********************
With cboItemNumber
.DataSource = dt
.DisplayMember = "ItemNumber"
End With
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
|