Click here to Skip to main content
15,892,005 members
Home / Discussions / Database
   

Database

 
GeneralRe: Problem installing MS SQL Server 2000 Pin
Mike Dimmick24-Apr-05 22:55
Mike Dimmick24-Apr-05 22:55 
Generalview the tables in access database Pin
rana1838424-Apr-05 10:39
rana1838424-Apr-05 10:39 
GeneralRe: view the tables in access database Pin
numbrel25-Apr-05 3:51
numbrel25-Apr-05 3:51 
GeneralRe: view the tables in access database Pin
zheke4-May-05 18:05
susszheke4-May-05 18:05 
GeneralACCESS 2003 Inner join Clause problem Pin
Greeky24-Apr-05 7:19
Greeky24-Apr-05 7:19 
GeneralRe: ACCESS 2003 Inner join Clause problem Pin
radasys24-Apr-05 7:45
radasys24-Apr-05 7:45 
GeneralRe: ACCESS 2003 Inner join Clause problem Pin
Greeky24-Apr-05 8:04
Greeky24-Apr-05 8:04 
GeneralData Binding - DropDownList Pin
brian5523-Apr-05 4:32
brian5523-Apr-05 4:32 
I have posted this problem a few times now in other areas. I have received some repsoinses but all suggestions fail. I have placed many statments in the code to verify that the data is being read. IT is. The only issue is the dataBind statement. I'm getting very frustrated!

I have many examples of how to bind a dropdownlist but NONE match the code that is generated in VS .NET. Since I am new to .NET and web programming I am having difficulty following the gerneated code. I am convinced my problem is in the way I am binding the data. The eror I get is

"Index 0 is not non-negative and below total rows count."

and it ocurs in the following line

DropDownList1.DataBind();

Here is some of the code. If you are intereseted in helping me I can post all of it.
 <br />
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
if (!Page.IsPostBack) <br />
{<br />
BindListToDropDown();<br />
}<br />
}<br />
<br />
#region Web Form Designer generated code<br />
override protected void OnInit(EventArgs e)<br />
{<br />
//<br />
// CODEGEN: This call is required by the ASP.NET Web Form Designer.<br />
//<br />
InitializeComponent();<br />
base.OnInit(e);<br />
}<br />
<br />
/// <br />
/// Required method for Designer support - do not modify<br />
/// the contents of this method with the code editor.<br />
/// <br />
private void InitializeComponent()<br />
{ <br />
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();<br />
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();<br />
this.dbListOfAirports1 = new dbListOfAirports();<br />
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();<br />
((System.ComponentModel.ISupportInitialize)(this.dbListOfAirports1)).BeginInit();<br />
this.DropDownList1.DataBinding += new System.EventHandler(this.Page_Load);<br />
// <br />
// oleDbDataAdapter1<br />
// <br />
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;<br />
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {<br />
new System.Data.Common.DataTableMapping("Table", "tblAirport", new System.Data.Common.DataColumnMapping[] {<br />
new System.Data.Common.DataColumnMapping("AirportCode", "AirportCode"),<br />
new System.Data.Common.DataColumnMapping("AirportID", "AirportID"),<br />
new System.Data.Common.DataColumnMapping("AirportName", "AirportName"),<br />
new System.Data.Common.DataColumnMapping("City", "City"),<br />
new System.Data.Common.DataColumnMapping("Latitude", "Latitude"),<br />
new System.Data.Common.DataColumnMapping("Longitude", "Longitude"),<br />
new System.Data.Common.DataColumnMapping("State", "State")})});<br />
// this.oleDbDataAdapter1.RowUpdated += new System.Data.OleDb.OleDbRowUpdatedEventHandler(this.oleDbDataAdapter1_RowUpdated);<br />
// <br />
// oleDbConnection1<br />
// <br />
this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=0;Data Source=""D:\MGDevelopment\SIMDAC Viewer\DB\simdac_be.mdb"";Jet OLEDB:Engine Type=5rovider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";<br />
// this.oleDbConnection1.InfoMessage += new System.Data.OleDb.OleDbInfoMessageEventHandler(this.oleDbConnection1_InfoMessage);<br />
// <br />
// dbListOfAirports1<br />
// <br />
this.dbListOfAirports1.DataSetName = "dbListOfAirports"; <br />
this.dbListOfAirports1.Locale = new System.Globalization.CultureInfo("en-US");<br />
// <br />
// oleDbSelectCommand1<br />
// <br />
this.oleDbSelectCommand1.CommandText = "SELECT AirportCode, AirportID, AirportName, City, Latitude, Longitude, State FROM" +<br />
" tblAirport";<br />
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;<br />
((System.ComponentModel.ISupportInitialize)(this.dbListOfAirports1)).EndInit();<br />
<br />
}<br />
#endregion<br />
<br />
private void BindListToDropDown()<br />
{<br />
try <br />
{<br />
oleDbConnection1.Open();<br />
OleDbDataReader OleDbReader = this.oleDbSelectCommand1.ExecuteReader();<br />
<br />
oleDbConnection1.Close();<br />
DropDownList1.DataSource=OleDbReader;<br />
DropDownList1.DataTextField = "AirportName";<br />
DropDownList1.DataValueField="AirportID";<br />
DropDownList1.DataBind();<br />
<br />
}<br />
catch(OleDbException ex) <br />
{<br />

GeneralRe: Data Binding - DropDownList Pin
Jerry Hammond23-Apr-05 5:58
Jerry Hammond23-Apr-05 5:58 
GeneralRe: Data Binding - DropDownList Pin
brian5524-Apr-05 4:19
brian5524-Apr-05 4:19 
GeneralRe: Data Binding - DropDownList Pin
Jerry Hammond24-Apr-05 4:54
Jerry Hammond24-Apr-05 4:54 
GeneralRe: Data Binding - DropDownList Pin
Jerry Hammond24-Apr-05 4:59
Jerry Hammond24-Apr-05 4:59 
GeneralRe: Data Binding - DropDownList Pin
rudy.net26-Apr-05 19:26
rudy.net26-Apr-05 19:26 
GeneralRe: Data Binding - DropDownList Pin
Illegal Operation24-Apr-05 2:58
Illegal Operation24-Apr-05 2:58 
GeneralRe: Data Binding - DropDownList Pin
brian5524-Apr-05 4:22
brian5524-Apr-05 4:22 
GeneralProblem with trigger on tables and views Pin
blbecek.pitomej22-Apr-05 23:53
blbecek.pitomej22-Apr-05 23:53 
GeneralRe: Problem with trigger on tables and views Pin
Member 190801324-Apr-05 8:23
Member 190801324-Apr-05 8:23 
GeneralRe: Problem with trigger on tables and views Pin
blbecek.pitomej25-Apr-05 10:09
blbecek.pitomej25-Apr-05 10:09 
GeneralUpdate Question Pin
rudemusik22-Apr-05 11:43
rudemusik22-Apr-05 11:43 
GeneralRe: Update Question Pin
Yulianto.22-Apr-05 19:25
Yulianto.22-Apr-05 19:25 
Generalequivalent to OFFSET Pin
Drew Stainton22-Apr-05 11:08
Drew Stainton22-Apr-05 11:08 
GeneralRe: equivalent to OFFSET Pin
Colin Angus Mackay22-Apr-05 11:55
Colin Angus Mackay22-Apr-05 11:55 
GeneralRe: equivalent to OFFSET Pin
Drew Stainton22-Apr-05 13:22
Drew Stainton22-Apr-05 13:22 
GeneralAlternative to dynamic sp's Pin
totig22-Apr-05 2:16
totig22-Apr-05 2:16 
GeneralRe: Alternative to dynamic sp's Pin
Mike Dimmick22-Apr-05 3:51
Mike Dimmick22-Apr-05 3:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.