I get the error that "Argument"1 ": cannot convert from
'string' to 'System.Data.Da taRow' at the foreach loop to add rows to the
DataTable...any ideas how to fix this?
Paul
=============== =============== =============== =====
private void button1_Click(o bject sender, System.EventArg s e)
{
richTextBox1.Te xt=null; //Clear
the RichTextBox
WebRequest req =
WebRequest.Crea te("http://www.sec.gov/Archives/edgar/daily-index/" +
"company." + "20041222" + ".idx"); // Create the Request object
WebResponse response = req.GetResponse (); //Create
the Response object
Stream stream = response.GetRes ponseStream(); //Create a
Stream
StreamReader sr = new StreamReader(st ream); //Open the file in
a stream reader
DataSet result = new DataSet(); //The DataSet
to Return
//StreamReader sr = new StreamReader("c :\\test.txt"); //Read From A
File instead of a webreques
//---------------------------------------------------------------------------------------------------
string AllData1 = sr.ReadToEnd(); //Read the rest of
the data in the file.
result.Tables.A dd("MyNewTable" ); //Add DataTable to hold
the DataSet
result.Tables["MyNewTable "].Columns.Add("D ata"); //Add a single
column
string[] rows = AllData1.Split( "\r\n".ToCharAr ray()); //Split off each
row at the Carriage Return/Line Feed
foreach(string r in rows)
{
result.Tables["MyNewTable "].Rows.Add(r); //Add the row to the
DataTable/DataSet
}
for (int i = 1; i <= 8; i++)
{
result.Tables["MyNewTable "].Rows.RemoveAt( 0); //Remove first 8 rows
from the DataTable/DataSet
}
//---------------------------------------------------------------------------------------------------
dataGrid1.SetDa taBinding(resul t, "MyNewTable "); //Binds DataGrid to
DataSet,display ing datatable.
} 2 5504
Hi a,
As the error says you cannot add String as DataRow. You need to pass in a DataRow or an array of objects, one for each column.
foreach(string r in rows)
{
DataRow row = result.Tables["MyNewTable "].NewRow();
row[0] = r;
result.Tables["MyNewTable "].Rows.Add(row);
}
Alternately you could do
foreach(string r in rows)
{
result.Tables["MyNewTable "].Rows.Add(new string[]{r});
}
On Fri, 06 May 2005 19:01:01 +0200, a <a@discussions. microsoft.com> wrote: I get the error that "Argument"1 ": cannot convert from 'string' to 'System.Data.Da taRow' at the foreach loop to add rows to the DataTable...any ideas how to fix this?
Paul
=============== =============== =============== =====
private void button1_Click(o bject sender, System.EventArg s e) { richTextBox1.Te xt=null; //Clear the RichTextBox
WebRequest req = WebRequest.Crea te("http://www.sec.gov/Archives/edgar/daily-index/" + "company." + "20041222" + ".idx"); // Create the Request object WebResponse response = req.GetResponse (); //Create the Response object Stream stream = response.GetRes ponseStream(); //Create a Stream StreamReader sr = new StreamReader(st ream); //Open the file in a stream reader DataSet result = new DataSet(); //The DataSet to Return
//StreamReader sr = new StreamReader("c :\\test.txt"); //Read From A File instead of a webrequest //--------------------------------------------------------------------------------------------------- string AllData1 = sr.ReadToEnd(); //Read the rest of the data in the file.
result.Tables.A dd("MyNewTable" ); //Add DataTable to hold the DataSet result.Tables["MyNewTable "].Columns.Add("D ata"); //Add a single column
string[] rows = AllData1.Split( "\r\n".ToCharAr ray()); //Split off each row at the Carriage Return/Line Feed
foreach(string r in rows) { result.Tables["MyNewTable "].Rows.Add(r); //Add the row to the DataTable/DataSet }
for (int i = 1; i <= 8; i++) { result.Tables["MyNewTable "].Rows.RemoveAt( 0); //Remove first 8 rows from the DataTable/DataSet }
//---------------------------------------------------------------------------------------------------
dataGrid1.SetDa taBinding(resul t, "MyNewTable "); //Binds DataGrid to DataSet,display ing datatable. }
--
Happy coding!
Morten Wennevik [C# MVP]
Morten:
Thank you very much for the help. I didn't know how to write that.
Paul
--------------------------------------------------------------------------
"Morten Wennevik" wrote: Hi a,
As the error says you cannot add String as DataRow. You need to pass in a DataRow or an array of objects, one for each column.
foreach(string r in rows) { DataRow row = result.Tables["MyNewTable "].NewRow(); row[0] = r; result.Tables["MyNewTable "].Rows.Add(row); }
Alternately you could do
foreach(string r in rows) { result.Tables["MyNewTable "].Rows.Add(new string[]{r}); }
On Fri, 06 May 2005 19:01:01 +0200, a <a@discussions. microsoft.com> wrote:
I get the error that "Argument"1 ": cannot convert from 'string' to 'System.Data.Da taRow' at the foreach loop to add rows to the DataTable...any ideas how to fix this?
Paul
=============== =============== =============== =====
private void button1_Click(o bject sender, System.EventArg s e) { richTextBox1.Te xt=null; //Clear the RichTextBox
WebRequest req = WebRequest.Crea te("http://www.sec.gov/Archives/edgar/daily-index/" + "company." + "20041222" + ".idx"); // Create the Request object WebResponse response = req.GetResponse (); //Create the Response object Stream stream = response.GetRes ponseStream(); //Create a Stream StreamReader sr = new StreamReader(st ream); //Open the file in a stream reader DataSet result = new DataSet(); //The DataSet to Return
//StreamReader sr = new StreamReader("c :\\test.txt"); //Read From A File instead of a webrequest //--------------------------------------------------------------------------------------------------- string AllData1 = sr.ReadToEnd(); //Read the rest of the data in the file.
result.Tables.A dd("MyNewTable" ); //Add DataTable to hold the DataSet result.Tables["MyNewTable "].Columns.Add("D ata"); //Add a single column
string[] rows = AllData1.Split( "\r\n".ToCharAr ray()); //Split off each row at the Carriage Return/Line Feed
foreach(string r in rows) { result.Tables["MyNewTable "].Rows.Add(r); //Add the row to the DataTable/DataSet }
for (int i = 1; i <= 8; i++) { result.Tables["MyNewTable "].Rows.RemoveAt( 0); //Remove first 8 rows from the DataTable/DataSet }
//---------------------------------------------------------------------------------------------------
dataGrid1.SetDa taBinding(resul t, "MyNewTable "); //Binds DataGrid to DataSet,display ing datatable. } -- Happy coding! Morten Wennevik [C# MVP] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: tshad |
last post by:
I am getting the error:
****************************************************************************
Array does not have that many dimensions.
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.IndexOutOfRangeException: Array does not have that
many dimensions.
|
by: Dacuna |
last post by:
I have a dataset that I created programmatically and bind to a datagrid.
When I add a row and I .show the form I get an error "Error creating window
handle"
This only happens if I have the code to add the row active. If I comment it
out then the form loads successfully (without any records, obviously).
Below is the code:
'-----------------------------Code Starts
|
by: JSantora |
last post by:
Essentially, InsertAT is broken!
For the past couple of hours, I've been getting this "Parameter name:
'-2147483550' is not a valid value for 'index'." error.
Apparently, its caused by having manually inserted a row in the table
bound to the Combo box. The InsertAt Method of adding a row just does
not work.
Hope this helps anyone with this problem.
john
|
by: diesel |
last post by:
Ok, once again I'm at my wits' end with a VB.Net problem.
I have a button which opens a wizard that allows the user to enter a
new record to a table. I have a datatable called dtItems that stores
the data from a table named Items, and a dataview called dvItems that
is a sorted subset of the data in dtItems. I have a datagrid called
(yes, you guessed it) dgItems, which has dvItems as its datasource.
When the user hits the New Item...
|
by: cc |
last post by:
Hi,
I having created a simple WebService (in VS 2005) with just one WebMethod as
follows :
public DataTable GetProducts()
{
DataTable objDataTable = null;
// code for filling up the datatable
| |
by: Anish G |
last post by:
Hi All,
I am getting the below given error while running my application in live server. In my local machine, its working fine. Please help me as it is very urgent for me.
Exception from HRESULT: 0x800A03EC
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:...
|
by: Kapteyn's Star |
last post by:
Hi newsgroup
The program here given is refused by GCC with a error i cannot
understand. It says
rnd00.c: In function ‘main’:
rnd00.c:26: error: expected expression before ‘]’ token
How to make it compile? I also tried buf but that gives "segmentation
fault". Thanks in advanced.
|
by: jehugaleahsa |
last post by:
Hello:
We wrote an entire application where we add our DataRows to our
DataTables immediately. However, we have to shut off our constraints
to do this. We would like to use detached DataRows to circumvent this.
What do you normally do to track detached DataRows? Is there a way to
retrieve them? or do I have to stored them in some temporary location?
Thanks for any input!
|
by: jehugaleahsa |
last post by:
Hello:
I am binding a DataGridView with a BindingList<T>, where T is a custom
business object that implements INotifyPropertyChanged.
When you bind a DataGridView to a DataTable, it has this cool little
feature - it will not call DataTable.Rows.Add until after you leave
the DataGridView row. This is cool because it lets your user edit the
record as much as needed to get it into a valid state before actually
adding it to the DataTable.
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |