PC Review


Reply
Thread Tools Rate Thread

Re: vbc cant find system.data.sqlClient.sqlConnection

 
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      28th Jul 2003
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

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: winnt\microsoft.net\framework\v1.1.4322\vbc.exe - error =?Utf-8?B?Sm9obiBR?= Microsoft Dot NET Framework 0 23rd May 2004 03:21 AM
URGENT: Vbc fails with error code 128 Stan Kondrat Microsoft Dot NET Framework 0 17th Nov 2003 04:10 PM
vbc compile error Greg Microsoft Dot NET Framework 1 8th Aug 2003 05:03 PM
compiler error: vbc : Command line error BC2001 : file 'system.drawing.dll,' could not be found Pablo Villa Microsoft Dot NET Framework 2 6th Aug 2003 02:15 AM
stuck in the first VBC/WSDL example Elsanto666 Microsoft Dot NET Framework 0 8th Jul 2003 05:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:25 AM.