Errors when compiling, any ideas??

B

brin

I have the following vb class and am trying to compile it using vbc.exe. I
receive errors stating that System.Data and System.Data.SqlClient cannot be
imported. I am fairly new to this, any help would be gratefully recieved.

Imports System
Imports System.Data.SqlClient
Imports System.Data
Imports System.Configuration

Namespace DBConnect

Public Class connect

protected conn as SqlConnection

Public Sub New()
conn = New SqlConnection(
"Server=localhost;uid=name;pwd=pass;database=db" )
End Sub

protected sub openConn()
conn.open()
end sub

protected sub closeConn()
conn.close()
end sub

End Class
End Namespace

Cheers

Brin
 
P

Patrice

It is likely tou don't have a reference to the System.Data.dll. See the /r
option.

Patrice
 
H

Hans Kesting

brin said:
I have the following vb class and am trying to compile it using vbc.exe. I
receive errors stating that System.Data and System.Data.SqlClient cannot be
imported. I am fairly new to this, any help would be gratefully recieved.

Imports System
Imports System.Data.SqlClient
Imports System.Data
Imports System.Configuration

You not only need an "Imports" statement ("using" in C#),
you also need to add a reference to System.Data to your project.

(to be a bit more precise: you don't really *need* that "Imports",
you can also type the complete namespace-path, but even then
you *need* to add the reference)

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top