index > .NET Framework Data Access and Storage > Datatable value not displaying!!!

Datatable value not displaying!!!

Hello,

I'm new to ado.net. Here is the code which i use to declare the dataTable:

DataTable dtable = new DataTable("dtable");

dtable.Columns.Add("SID",typeof(System.String));

dtable.Columns.Add("givenName", typeof(System.String));

dtable.Columns.Add("sn", typeof(System.String));

dtable.Columns.Add("mail", typeof(System.String));

dtable.Columns.Add("tel", typeof(System.String));

dtable.Columns.Add("mobile", typeof(System.String));

dtable.Columns.Add("office", typeof(System.String));

and here is the code for adding a new row.

for (int i = 0; i <src.Count - 1; i++)

{

DataRow tempRow = dtable.NewRow();

tempRow.ItemArray[0] = SID[ i ];

tempRow.ItemArray[1] = givenName[ i];

tempRow.ItemArray[2] = sn[ i];

tempRow.ItemArray[3] = mail[ i];

tempRow.ItemArray[4] = tel[ i];

tempRow.ItemArray[5] = mobile[ i];

tempRow.ItemArray[ 6] = office[ i];

dtable.Rows.Add(tempRow);

}

dtable.AcceptChanges();

but somehow when i'm trying to display the item using response.write it doesn't give me anything. I have checked the SNIdea is bringing the records.

Solution?

 




Prince of Dhump
Prince of Dhump
Your code looks OK. Paste your response.write code.

Did you check the length of src.Count is greater than 1? Otherwise the for loop won't loop once.
kbradl1

You shouldn't use ItemArray because it's a copy of the datarow objects.

You should do something like

dr[0] = ...




This posting is provided "AS IS" with no warranties, and confers no rights.
Bill Lin - MSFT

okay Bill,

This kind of freak me out as there wasn't anything mention in msdn about this way. Can you atleast tell me a good book on ado.net as I would now be working most of the time with ado.net database applications using C#.

Cheers




Prince of Dhump
Prince of Dhump

I would recommend David's book:

http://www.microsoft.com/mspress/books/8744.asp




This posting is provided "AS IS" with no warranties, and confers no rights.
Bill Lin - MSFT
reply 5

You can use google to search for other answers

 

More Articles

• How to make http connections to an MS SQL server and retrieve dat...
• How to synchronize XML file with DataSet if XML schema is differe...
• QUERY written in MS Access does not work with adodb
• Using diffgram to update database
• Problem looping over rows created within the same loop
• Problem with : The type or namespace name 'myDataset' could not b...
• streaming video
• Problem | Oracle 9i Release + With Vb.Net 2005
• How to Connect Microsoft Access database from the Server which is...
• How To Easily Change Connection To Access Database Created Using ...
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• transaction problem
• Error .Net SqlClient Data Provider when
• after publish the program, if i wanna ch
• Wish list for .NET 3.0 framework
• DataAdapters - Please help Im confused
• How do I display the Connection string b
• subquery doesn't work (using VC#, *.csv,
• Data Sources Window
• questions about Automatically Generating
• Display autonumber
• Pulling Data From Two Different Databases
• catcha sqlexception and column
• Importing An Excel Sheet In SQL SERVER 2
• VB Express creating new project
• Getting deleted child rows for a "S

Hot Articles

• Unable to cast object of type 'System.Ob
• Dataset with two tables from different s
• Using A Variable In An Excel Query For V
• default value 0
• Could not find stored procedure 'dbo.asp
• System.Transactions issue
• connection and fucntions
• Problem with c# and Access DB
• SQLBulkCopy and text files.
• Connection String
• Typed DataSet Class not exposing its mem
• Fulfill inner joins and queries in a 3-t
• delete and update code at the same butto
• Database update works as console app, fa
• .Net 2.0 Web App linking to SQL 2000

Recommend Articles

• faster way of accessing CSV files
• Updating a DB and getting an id
• Retrieve output inserted multiple columns
• Interesting behavior causing: "Ther
• XML scheme that causing crashing of the
• Error when saving a "Computed"
• SqlException: Data has been modified by
• wwhich version of ADO.NET for DB Mirrori
• ODBC Wizard can't create insert/update/d
• how to read only certain fields(columns)
• i need help with passing parameters in t
• Unable to Update/Insert a new row into t
• URGENT Problem with Greek Character from
• Size of Dataset rows in BYTES
• Regional Settings, depending of the form