Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with Imports and SqlConnection
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Problem with Imports and SqlConnection
Miscellaneous
Thread ID:
00707445
Message ID:
00707445
Views:
73
I have run into a problem using Visual Studio.NET and a code-behind page. I am reading a couple of ASP.NET books, and all the examples have the code in the .aspx page. It's my understanding that it's better to put the code in the code behind page. Is that correct?

In my code-behind page, I have:
Imports System.Data
Imports System.Data.SqlClient

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  'Put user code to initialize the page here

  Dim conStockIndex As SqlConnection

  conStockIndex = New SqlConnection("connection string here")
End Sub
When I do this, Visual Studio.NET gives me an error:

Too many arguments to Public Sub New()

If I add System.Data.SqlClient to the Dim and New statements, everything works fine. Can someone tell my why I have to explicitly reference System.Data.SqlClient?
Chris McCandless
Red Sky Software
Next
Reply
Map
View

Click here to load this message in the networking platform