Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Sql Server Database is not responding in random ma

Author  Topic 

prashantbaranwal
Starting Member

3 Posts

Posted - 2012-08-11 : 04:39:10
I've created a database in MS-SQL and used it in my application.
But sometimes it doesn't responds randomly and throws an exception System.Data.DataRowView' does not contain a property with the name 'service_name' while the column is in my table.
Later on I've been dropped that DB and again created a new DB with new name but the problem remain persist.
But this issue has not been occurred with the other existing DBs.

I'm using this connection string:
<add name="testCon" connectionString="Data Source=Comp1;Initial Catalog=TestDB;Persist Security Info=True;User ID=test;Password=test;" providerName="System.Data.SqlClient"/>

and using this command on code behind
"select t.id, t.service_name from dbo.[Table_Name] t"
By using this command I'm filling a Drop Down-List and above prob raises.

This works properly on SQL but occurred at front-end

Please provide some proper solution ASAP.
Thanks in advance.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-08-11 : 08:29:51
Your SQL query certainly looks fine and I am not able to discern anything else that would be a problem. The error message indicates the exception in DataRowView - which leads me to believe that the problem may be in the .Net code.

The only suggestion I would have is to run the program from Visual Studio debugger and analyze the call stack and variables when the exception occurs.

If the error is too infrequent that it is not possible to do that, I would add exception handling code and trace as much detail as possible about the object that is bound to your drop down list.
Go to Top of Page

prashantbaranwal
Starting Member

3 Posts

Posted - 2012-08-13 : 02:28:15
Hi Sunita,
sample code is here:

SqlDataAdapter da = new SqlDataAdapter("select t.id, t.service_name from dbo.[Table_Name] t", testCon);
DataTable dtt = new DataTable();
da.Fill(dtt);
if (dtt.Rows.Count > 0)
{
ddl1_sel.DataSource = dtt.DefaultView;
ddl1_sel.DataTextField = "service_name";
ddl1_sel.DataValueField = "id";
ddl1_sel.DataBind();
ddl1_sel.Items.Insert(0, new ListItem("Select Service", "0"));
}

I've rechecked the code several times, but found no syntax and logical error.

you can see a discussion thread at
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataset/thread/eca8145d-4162-4fa0-9b48-18f31fc7d275
and
http://forums.asp.net/t/1832022.aspx/2/10?Re+Sql+Server+Database+is+not+responding+properly
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-08-13 : 06:56:51
Prashant, I don't have any thoughts other than what I had already indicated and what the people on that forum were suggesting - namely, run it from debugger or trace as much information about the DataTable and the DataRowView and examine those when the error happens.

For the simple data-binding you are using I don't see many places for it to go wrong, unless something unrelated is messing it up - for example, in some other part of the code, you were binding that control to a different Dataset (in error).
Go to Top of Page
   

- Advertisement -