Click here to Skip to main content
16,016,087 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How do I change JUST the color of a Group Boxs' line?????? Pin
Dave Kreskowiak21-Jun-06 9:18
mveDave Kreskowiak21-Jun-06 9:18 
QuestionModule Pin
Lansky20-Jun-06 5:18
Lansky20-Jun-06 5:18 
AnswerRe: Module Pin
Dave Kreskowiak21-Jun-06 9:14
mveDave Kreskowiak21-Jun-06 9:14 
QuestionDisable/Enable CD/DVD-Drive Pin
Lennard Fonteijn20-Jun-06 4:38
Lennard Fonteijn20-Jun-06 4:38 
AnswerRe: Disable/Enable CD/DVD-Drive Pin
progload20-Jun-06 6:38
progload20-Jun-06 6:38 
QuestiontreevieW in vb.net 1.1 Pin
constantinejones20-Jun-06 4:19
constantinejones20-Jun-06 4:19 
AnswerRe: treevieW in vb.net 1.1 Pin
Lennard Fonteijn20-Jun-06 4:45
Lennard Fonteijn20-Jun-06 4:45 
QuestionType SqlConnection is not defined Pin
Quecumber25620-Jun-06 3:53
Quecumber25620-Jun-06 3:53 
I recently bought a MSDN Visual Studio 2005 Professional Subscription and I am trying to learn VB.NET, specifically how to do use the ADO.NET stuff for database operations.

I have bought a reference book titled “Beginning VB.NET 2003” and I’m trying out this example:
'Import Data and SqlClient namespaces
Imports System.Data
Imports System.Data.SqlClient

Public Class Form1
Inherits System.Windows.Forms.Form
Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=pubs;user id=sa;password=")
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As DataSet = New DataSet()

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Set the SelectCommand properties...
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = _
"SELECT au_lname, au_fname, title, price " & _
"FROM authors " & _
"JOIN titleauthor on authors.au_id = titleauthor.au_id " & _
"JOIN titles ON titleauthor.title_id = titles.title_id " & _
"ORDER BY au_lname, au_fname"
objDataAdapter.SelectCommand.CommandType = CommandType.Text

'Open the database connection...
objConnection.Open()

'Fill the DataSet object with data...
objDataAdapter.Fill(objDataSet, "authors")

'Close the database connection
objConnection.Close()

'Set the DataGrid properties to bind it to our data...
grdAuthorTitles.DataSource = objDataSet
grdAuthorTitles.DataMember = "authors"

'Cleanup
objDataAdapter = Nothing
objConnection = Nothing
End Sub
End Class

I’m getting an error on this line:
Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=pubs;user id=sa;password=")

The SqlConnection statement after the New is giving me the error “Type ‘SqlConnection’ is not defined.”
Can anyone tell me why this is happening? The contructor for the data operations are imported at the beginning of the project. I have no idea what is wrong, or how to correct it.

Thank you,


Quecumber256
AnswerRe: Type SqlConnection is not defined Pin
Edbert P20-Jun-06 19:39
Edbert P20-Jun-06 19:39 
GeneralRe: Type SqlConnection is not defined Pin
Quecumber25621-Jun-06 3:49
Quecumber25621-Jun-06 3:49 
GeneralRe: Type SqlConnection is not defined Pin
Edbert P21-Jun-06 13:52
Edbert P21-Jun-06 13:52 
QuestionOnline Booking Pin
Daleen20-Jun-06 3:16
Daleen20-Jun-06 3:16 
AnswerRe: Online Booking Pin
mikanu20-Jun-06 9:42
mikanu20-Jun-06 9:42 
Generalto save multiple .bmp images Pin
Ganesh Nagargoje20-Jun-06 3:15
Ganesh Nagargoje20-Jun-06 3:15 
GeneralRe: to save multiple .bmp images Pin
toxcct20-Jun-06 3:21
toxcct20-Jun-06 3:21 
GeneralRe: to save multiple .bmp images Pin
Nitron20-Jun-06 3:22
Nitron20-Jun-06 3:22 
JokeRe: to save multiple .bmp images Pin
Don Miguel20-Jun-06 3:27
Don Miguel20-Jun-06 3:27 
GeneralRe: to save multiple .bmp images Pin
Monty220-Jun-06 3:28
Monty220-Jun-06 3:28 
JokeRe: to save multiple .bmp images Pin
toxcct20-Jun-06 3:52
toxcct20-Jun-06 3:52 
GeneralRe: to save multiple .bmp images Pin
Lennard Fonteijn20-Jun-06 4:43
Lennard Fonteijn20-Jun-06 4:43 
GeneralRe: to save multiple .bmp images [modified] Pin
Dave Kreskowiak20-Jun-06 5:26
mveDave Kreskowiak20-Jun-06 5:26 
GeneralRe: to save multiple .bmp images Pin
Dave Kreskowiak20-Jun-06 5:24
mveDave Kreskowiak20-Jun-06 5:24 
QuestionMaster/Detail datagrid Pin
JohnBeton20-Jun-06 1:41
JohnBeton20-Jun-06 1:41 
AnswerRe: Master/Detail datagrid Pin
JohnBeton20-Jun-06 22:33
JohnBeton20-Jun-06 22:33 
QuestionCrystal Report Logon Pin
giotis8220-Jun-06 1:32
giotis8220-Jun-06 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.