views:

29

answers:

2

So basically this code was working fine before. I had some computer issues and had to move the development folder around and when I reopened it, I am getting a "Type 'SqlConnection' is not defined" error on all of my pages, even though I am importing System.Data.SqlClient.

Intellisense seems to see that its imported, but I get the error whenever I try to build. Anyone what I can do to get the builder to realize that I've made the correct import again?

Imports System.Data.SqlClient

Partial Class Default11
Inherits System.Web.UI.Page
Dim patid As String
Dim term As Integer
Dim a1 As Integer
Dim a2 As Integer
Dim a3 As Integer

Dim connectionInfo As String = System.Configuration.ConfigurationManager.AppSettings("ConnectionInfo")
Dim connection As SqlConnection = New SqlConnection(connectionInfo)
Dim cmd As SqlCommand
Dim cmdStr As String

Extra info: Changing

Dim connection As SqlConnection = New SqlConnection(connectionInfo)

To

Dim connection As New SqlConnection(connectionInfo)

seems to get rid of the error, but I'd prefer not to have to go and change this on all of my pages.

A: 

Make sure you have System.Data referenced in your project.

David Basarab
Tried adding the reference to the page, to the web.config and through property pages with no luck. Did I miss one by chance?
Mercurybullet
A: 

Seems as though this was due to a weird issue when reinstalling Visual Studio. Apparently I had set it to be tuned for VB.net on the old install and chose C# when reinstalling.

As far as I can tell, this shouldn't have been a problem to begin with, but when I reset the settings to VB.net it cleared up. Unfortunately, I wasn't able to recreate the issue when reseting back to C# settings again. I guess it was just an unlucky fluke.

Mercurybullet