Hi All
I am using .NET Framework version 1.0.3705 to build a website.
Now i have made a webform and on that i have added a dropdown to the page
I bind this listbox to a datareader .
This does not happenm , i have no clue what the problem is
I am attaching the error
<font color='red' >
System.Web.Http Exception: DataBinder.Eval : 'System.Data.Co mmon.DbDataReco rd' does not contain a property with the name Davolio. at System.Web.UI.D ataBinder.GetPr opertyValue(Obj ect container, String propName) at System.Web.UI.D ataBinder.GetPr opertyValue(Obj ect container, String propName, String format) at System.Web.UI.W ebControls.List Control.OnDataB inding(EventArg s e) at System.Web.UI.C ontrol.DataBind () at TestApp.WebForm 1.getEmpDetails () in c:\inetpub\wwwr oot\testapp\web form1.aspx.cs:l ine 67
</font>
I am attaching the code too!
I have made the connection to the Northwind database , this is easilt available
Please advise what is going wrong if there is a KB article for the same?
<code>
private int getEmpDetails()
{
SqlConnection oSQLConn = new SqlConnection(" Password=New123 4;Persist Security Info=True;User ID=sa;Initial Catalog=Northwi nd;Data Source=IND-SPZ4D2K0319");
SqlCommand oSQLCmd;
SqlDataReader oSQLDataRead;
try
{ oSQLConn.Open() ;
oSQLCmd = new SqlCommand("sel ect * from employees",oSQL Conn);
oSQLCmd.Command Type = CommandType.Tex t;
oSQLDataRead = oSQLCmd.Execute Reader(CommandB ehavior.CloseCo nnection);
if(oSQLDataRead .Read())
{
//string strName = oSQLDataRead.Ge tValue(1).ToStr ing() + " " + oSQLDataRead.Ge tValue(2).ToStr ing();
//ddl01.Items.Add (strName);
ddl01.DataTextF ield = oSQLDataRead.Ge tValue(1).ToStr ing();
//ddl01.DataValue Field = oSQLDataRead.Ge tValue(1).ToStr ing();
ddl01.DataSourc e = oSQLDataRead;
ddl01.DataBind( );
}
return 1;
}
catch(Exception ex)
{
Response.Write( ex.ToString());
return -1;
}
}
</code> 1 1826
Got it guys!!!
The mistake is with my coding... sorry. The way to bind the thing was to assign the DataFieldValue and DataFieldText properties of a combo box or a Listbox to the column names and not to the value as I was doing it.
This solved the problem. So there is not issue with binding as the subject heading says!!!
Thanks,
"Sachin Kuchinad" wrote: Hi All
I am using .NET Framework version 1.0.3705 to build a website. Now i have made a webform and on that i have added a dropdown to the page
I bind this listbox to a datareader . This does not happenm , i have no clue what the problem is I am attaching the error
<font color='red' > System.Web.Http Exception: DataBinder.Eval : 'System.Data.Co mmon.DbDataReco rd' does not contain a property with the name Davolio. at System.Web.UI.D ataBinder.GetPr opertyValue(Obj ect container, String propName) at System.Web.UI.D ataBinder.GetPr opertyValue(Obj ect container, String propName, String format) at System.Web.UI.W ebControls.List Control.OnDataB inding(EventArg s e) at System.Web.UI.C ontrol.DataBind () at TestApp.WebForm 1.getEmpDetails () in c:\inetpub\wwwr oot\testapp\web form1.aspx.cs:l ine 67
</font>
I am attaching the code too! I have made the connection to the Northwind database , this is easilt available Please advise what is going wrong if there is a KB article for the same?
<code>
private int getEmpDetails() { SqlConnection oSQLConn = new SqlConnection(" Password=New123 4;Persist Security Info=True;User ID=sa;Initial Catalog=Northwi nd;Data Source=IND-SPZ4D2K0319"); SqlCommand oSQLCmd; SqlDataReader oSQLDataRead; try { oSQLConn.Open() ; oSQLCmd = new SqlCommand("sel ect * from employees",oSQL Conn); oSQLCmd.Command Type = CommandType.Tex t;
oSQLDataRead = oSQLCmd.Execute Reader(CommandB ehavior.CloseCo nnection); if(oSQLDataRead .Read()) { //string strName = oSQLDataRead.Ge tValue(1).ToStr ing() + " " + oSQLDataRead.Ge tValue(2).ToStr ing(); //ddl01.Items.Add (strName); ddl01.DataTextF ield = oSQLDataRead.Ge tValue(1).ToStr ing(); //ddl01.DataValue Field = oSQLDataRead.Ge tValue(1).ToStr ing(); ddl01.DataSourc e = oSQLDataRead; ddl01.DataBind( ); } return 1; } catch(Exception ex) { Response.Write( ex.ToString()); return -1; } }
</code> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jason Huang |
last post by:
Hi,
Is it possible to bind DataReader to a DataGrid in C# windows form? And
how?
And can we update data in a DataSet by using the DataReader?
Thanks for help.
Jason
|
by: Donald Williamson |
last post by:
I have a DataReader that I am binding to a Repeater control. In the
DataReader, I have two fields: 'Name1' and 'Name2'
'Name1' will always have a person's name. Name2 periodically has a person's
name. So the question is if there is a value in 'Name2', I want to display
only that name. Otherwise, display 'Name1'
Any help on how to do this?
Using VS.NET - vb
|
by: Brian Conway |
last post by:
I need some help on binding a datareader to a dropdown box. I have included
the code for the dropdown below. It builds with no errors, but returns no
results. Any help would be appreciated.
private void DropDownList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
OleDbConnection conn = new OleDbConnection("DataSource=ntdrp001.world;
|
by: sck10 |
last post by:
Hello,
I have a GridView that is using the following to connect to a SQL Server
2000 stored procedure:
<asp:SqlDataSource
ID="dsWebDocList" SelectCommand="sp_web_WebDocument"
ConnectionString="<%$ ConnectionStrings:cnnSQL_Connect %>" Runat="server">
<SelectParameters>
<asp:Parameter Type="String" DefaultValue="FindWebDocAll"
|
by: Ashwani Gaur |
last post by:
Hi all,
It may be a very simple query, but i am stuck with having
millions of record showing instantly in chunks of 100 or
200 record(not a paging concept), in vb i use to bind the
data to ado datacontrol which is binded to datagrid and
data is instantly shown using ado events and methods in a
user friendly manner i.e data is shown and fetched
simultaneously.
| |
by: Support |
last post by:
Hi All,
I am working in VB.NET.
I have a data bound control (combobox) which I want to fill with a certain
field of my table from database ( SQL as backend).
The issue is, I want these values to fill the combo at the index specified
by me, ie, not the usual 0,1,2.... by default. Also, not dataset, but I am
using dataReader.
Can anyone send me the sample code for the same?
Thanks for your help.
|
by: tshad |
last post by:
I am using VS 2003 and trying to build a standalone application. I have
been writing all my asp.net work using DW and am just now trying to build a
application that will read some of the tables I had written out from my web
apps.
I can get my DataReader to read my data fine. But I wanted to use a
DataGrid, but it is apparently completely different????
I can do:
|
by: Alan Silver |
last post by:
Hello,
I have a generic method in a utility class that grabs an sqldatareader
and returns it. Due to the fact that (AFAIK), you can't close the
database connection before you've read the data, this method doesn't
close it, it just returns the datareader. The calling code uses the
datareader and then just lets it drop out of scope, to be picked up by
the garbage collector.
Is this a problem? A friend of mine suggested to me that not...
|
by: Varangian |
last post by:
Hi all,
the question I want to ask if the conversion of a DataReader to a Table
looping through the DataReader is better than using the Fill Method of
the DataAdapter... I'm asking because internally the DataAdapter uses
the DataReader... so whats the deal of writing a method that converts a
DataReader into a DataTable ?
Thanks!
|
by: RAB |
last post by:
I have the following code:
<%@ Page Language="VB" %>
<script runat="server">
Function GetName() As System.Data.IDataReader
Dim connectionString As String = 'path to datasource
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection
(connectionString)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |