Hello,

I recently migrated our ASP.NET application to another server. We copied everything exactly as it is, from ASP.NET files to SQL Database with its stored procedures and everything.

Now when we goto the app's root directory, the login page pops up as usual, we login and everything is fine up to that moment. But then when we try to see the data list, we get 0 results. And when we try to see the contact's list, we get this error.

I called the support of the app and they're just as baffled as I am. Please help me!!

A field or property with the name 'Department' was not found on the selected data source.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A field or property with the name 'Department' was not found on the selected data source.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): A field or property with the name 'Department' was not found on the selected data source.]
System.Web.UI.WebControls.BoundField.GetValue(Control controlContainer) +1618551
System.Web.UI.WebControls.BoundField.OnDataBindField(Object sender, EventArgs e) +64
System.Web.UI.Control.OnDataBinding(EventArgs e) +99
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +92
System.Web.UI.Control.DataBind() +15
System.Web.UI.Control.DataBindChildren() +211
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102
System.Web.UI.Control.DataBind() +15
System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +155
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +2417
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +14
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.WebControls.GridView.get_Rows() +34
RealEstate.Web.UserControls.ucContacts.Page_PreRender(Object sender, EventArgs e) in E:\Inetpub\wwwroot\Custom\RealEstate\RealEstate.Web\UserControls\ucContacts.ascx.cs:136
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnPreRender(EventArgs e) +8686422
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

Version Information: Microsoft .NET Framework Version:2.0.50727.3623; ASP.NET Version:2.0.50727.3618

Does the login interact with the same SQL db that the data is bound to?

I suppose so. This is the connectionString in web.config, it's the only link to the database.

<add name ="LocalSQLServer" connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=DB_Name;"/>

Hmmm. I am not overly familiar with SQLEXPRESS (I only use MySQL and sometimes access). But shouldn't there be a user name,password, and IP (even if just localhost) in that string? Maybe you are using ODBC - if this is the case, have you registered your database in your ODBC datasources (in Control Panel->Administrative Tools->ODBC Data Sources)

If the connectionString is wrong then how is it fetching the usernames and passwords for the login page?

have you registered your database in your ODBC datasources (in Control Panel->Administrative Tools->ODBC Data Sources)

The database is .mdf - I went there and tried to add the extension but could not find it.

If the connectionString is wrong then how is it fetching the usernames and passwords for the login page?

The database is .mdf - I went there and tried to add the extension but could not find it.

Not sure (it's not my app lol). You didn't sound overly confident that the login info was coming from the same db as the problematic one. Do you have any way to check out the DB (its data and structure) from outside your program? It could be as simple as the tables not being built properly.

Not sure (it's not my app lol). You didn't sound overly confident that the login info was coming from the same db as the problematic one. Do you have any way to check out the DB (its data and structure) from outside your program? It could be as simple as the tables not being built properly.

Well, that was my mistake. Yes, I can check the database structure and I can clearly see the users table with my username and password in it as well as all the other usernames that I have created earlier. So to answer you question, yes, it's definitely connected to the same database.

It's the only database I have anyway.

Ok, so you can see the structure of the login info tables. Can you see the Contacts list table (or whatever table has the 'department' field)?

Are you familiar with SQL queries? If you are, you could try using a raw select statement to simulate what your web control is doing. It could be as simple as you needing to rebind the datasource (maybe the path is slightly different than it used to be).

Ok, so you can see the structure of the login info tables. Can you see the Contacts list table (or whatever table has the 'department' field)?

Yes, I can see the table and the designated field. They're all there.

rebind the datasource

How do I do that?

Thanks for your time.

I think you were right. I toyed around with the connectionString and changed it to this

<add name="LocalSQLServer" connectionString="Data Source=.\sqlexpress;Initial Catalog=DB_Name;Persist Security Info=True;User ID=sa;Password=****;Packet Size=4096;"/>

And now I'm getting this error

System.Data.SqlClient.SqlException: Login failed for user 'sa'.

This talks about databinding with controls (assuming this is an ASP project).

Do you have the code for your datasource (this might be in the designer code if you added it through the GUI and not programatically). It's very difficult to troubleshoot your problems without any relevant code.

I think you were right. I toyed around with the connectionString and changed it to this

And now I'm getting this error

Are you sure that you are using the correct username/password combo?

In MySQL the base login name is called 'root' - but this might be different with sqlexpress.

Are you sure that you are using the correct username/password combo?

Well, I took the files and database exactly as they were on the old server and pasted them into the new server. I didn't check what's the default username on sqlexpress.
I think I should look into that.

Well, I took the files and database exactly as they were on the old server and pasted them into the new server. I didn't check what's the default username on sqlexpress.
I think I should look into that.

Sounds to me like it was probably set up as an ODBC datasource (or some other registered datasource) on the old system. When you register a datasource with windows you give it the default username and password for that connection. If the other system is available - check out it's ODBC datasource list and let me know what you find.

I went there and it's empty. Under "User DSN" the list is empty.

I went there and it's empty. Under "User DSN" the list is empty.

What about SystemDSN?

It's also empty.

Interesting... Well try tracking down the username and password for your db.

I did. Turns out I had sql authentication mode disabled. So I enabled it and the page opened.

Now when I click on "Contact List" I get the same error I started with

A field or property with the name 'Department' was not found on the selected data source.

Can you zip the project then post it (assuming it's not very big)? Might make things easier lol.

Here you go, it's 1.7MB
I can't upload the DB as well as it's 2GB

EDIT: I had to remove the file as it contained login info what not.

This is the list of folders and files, let me know which file you'd like to view.

http://i.imgur.com/Grc12.jpg

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.