You are using "Imports" on a specific object.
Imports is used to bring in a namespace into a project so you don't have to
type it all out.
//this imports the namespace that holds the SqlConnection object.
Imports System.Data.SqlClients
//this would be how to reference it in code.
SqlConnection sc as new SqlConnection()
//if you didn't have the Imports directive you would have to access a
SqlConnection by the full name
System.Data.SqlClients.SqlConnection sc As New
System.Data.SqlClients.SqlConnection()
Try changing the imports line you have at the top to import the namespace
that holds the object.
Imports System.Data.SqlClient
Imports System
here is a sample command line you might want to use.
vbc /r:System.Data.dll, System.dll Foo.vb /t:exe
I am not to up to date on the command line compiler, but try this one out.
HTH,
bill
> >> C:\VisualStudioProjects\ConsoleConnect1>vbc
> >> Module1.vb /t:exe
"Steve" <(E-Mail Removed)> wrote in message
news:011101c35525$0ec4b830$(E-Mail Removed)...
> Thanks bill,
> Can you explain a bit more on what I need to do to
> rectify the problem or can I email you direct.
> Cheers
> Steve
> >-----Original Message-----
> >Imports System.Data.SqlClient;
> >
> >the SqlConnection is a specific object....inside a
> namespace.
> >
> >HTH,
> >
> >bill
> >
> >"steve" <(E-Mail Removed)> wrote in
> message
> >news:098501c3551f$c2f83760$(E-Mail Removed)...
> >> Hi, I got the following error when trying to compile
> the
> >> code to test a db connection (lower down the page), can
> >> anyone help me understand why the vbc isn't recognising
> >> the objects?
> >> ERROR:-
> >>
> >> C:\VisualStudioProjects\ConsoleConnect1>vbc
> >> Module1.vb /t:exe
> >> Microsoft (R) Visual Basic .NET Compiler version
> 7.00.9466
> >> for Microsoft (R) .NET Framework version 1.00.3705.288
> >> Copyright (C) Microsoft Corporation 1987-2001. All
> rights
> >> reserved.
> >>
> >> C:\VisualStudioProjects\ConsoleConnect1\Module1.vb(1) :
> >> error BC30466: Namespace
> >> or type 'SqlConnection' for the
> >> Imports 'System.Data.SqlClient.SqlConnection' c
> >> annot be found.
> >>
> >> Imports System.Data.SqlClient.SqlConnection
> >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> C:\VisualStudioProjects\ConsoleConnect1\Module1.vb
> (13) :
> >> error BC30002: Type 'Sy
> >> stem.Data.SqlClient.SqlConnection' is not defined.
> >>
> >> Dim objConn As New
> >> System.Data.SqlClient.SqlConnection(sConnection)
> >>
> >> CODE:-
> >>
> >> Imports System.Data.SqlClient.SqlConnection
> >> Imports System.Console
> >> Module Module1
> >>
> >> Private Const sConnection As String = "Password=;"
> & _
> >> "Persist
> >> Security Info=True;" & _
> >> "User
> ID=sa;"
> >> & _
> >> "Initial
> >> Catalog=pubs;" & _
> >> "Data
> >> Source=myServer"
> >> Sub Main()
> >> Dim objConn As New
> >> System.Data.SqlClient.SqlConnection(sConnection)
> >>
> >> Try
> >> objConn.Open()
> >> Catch myException As System.Exception
> >> System.Console.WriteLine
> (myException.Message)
> >> End Try
> >> System.Console.WriteLine(sConnection)
> >> System.Console.Read()
> >>
> >> End Sub
> >
> >
> >.
> >
|