Why is SQL Server not recognized, even though I

2020-04-14 07:25发布

It seems that whenever I add anything to my project which uses code in my commonClass.vb file, I get errors about SQL Server not being recognized.

I do have a reference to DAL05.

SQL Server in the file shows it's not recognized, as does the DAL05.DataAccess imports:

enter image description here

Do I need to add another reference? Another or a different Imports? Or what?

As you can see, I am referencing DAL05, and it is not offered as a way for SQL Server to be recognized:

enter image description here

UPDATE:

A possibly significant factoid: A difference between the legacy project - which has no problem with recognizing SQL Server - is that it does not even have a References folder; DAL05.dll (and DAL05.pdb) are below \<project>\bin\Common

So should I force a Bin and Bin\Common folder into my project (via Windows Explorer) and then add those files there? Is that the solution (no pun intended)?

UPDATE 2:

Okay, now this is getting really weird; based on a clue I found here about a similar issue, I prepended DAL095.DataAccess. to the SQL Server like so:

Dim sqlDAL As New DAL05.DataAccess.SQLServer(

The results are as follows:

  1. This does NOT reduce the number of errors.

  2. This seems superfluous/moot because DAL05.DataAccess." is grayed out.

  3. The red underscore on the second and last r of SQLServer is NOT removed.

Yet, when I 2-click the top "Type 'SQLServer' is not defined." error msg from the error list, it no longer takes me to the references to "SQLServer" to which I have appended the seemingly useless "DAL05.DataAccess" but go instead only to the "naked" references to "New SQLServer":

enter image description here

In case it means anything, a failing function is:

Public Function GetUserInfo(ByVal userid As String, ByVal password As String, ByVal memberno As String) As DataTable
    Dim sqlDAL As New SQLServer(System.Configuration.ConfigurationManager.AppSettings("OrderEnterConnection"))
    Dim dset As DataSet
    dset = sqlDAL.runSQLDataSet("Exec up_GetUserData_Web_2012 '" + userid + "','" + password + "','" + memberno + "'")
    Return dset.Tables(0)
End Function

UPDATE 3:

Ever stranger: after I changed this:

Imports DAL05.DataAccess

...to this:

Imports DAL05.DataAccess.SQLServer

I was finally given some seemingly sensible Intellisense help; it said,

Import DAL05.DataAccess.SQLServer' and other missing references?

I accepted that, but I still have the same 204 errors.

And Imports DAL05.DataAccess.SQLServer is completely grayed out, with the following helpful msg:

enter image description here

1条回答
够拽才男人
2楼-- · 2020-04-14 08:08

As @B. Clay Shannon (the OP) Commented the solution is:

1) getting rid of all the TFS vestiges (files and entries in the .sln file);

2) Deleting the .suo files and (probably had nothing to do with it)

3) Opening Visual Studio as administrator.

Another Case

I was having the same problem and i does the following steps

1) closing all the open tabs, cleaning all the projects and rebuilding,

2) shutting down all my Visual Studio instances

3) restarting my computer.

and it fixed the issue

查看更多
登录 后发表回答