This worked in the command window while in debug mode
?table.Rows[0].ItemArray["ColumnName"].ToString()
"f0165f94-648f-4997-b578-11d89c8b1f61"
But gives the error below when I compile.
Cannot implicitly convert type 'string' to 'int' and the word ColumnName is
underlined.
Here is a code snippett (with error line marked with an asterisk):
DataSet ds = new DataSet();
ds.ReadXml(@"D:\Data\test.xml", XmlReadMode.ReadSchema);
foreach (DataTable table in ds.Tables)
{
for (int index = 0; index <= table.Rows.Count; index++)
{
{
SqlCommand command = new SqlCommand("ImportData", conn);
command.CommandType = CommandType.StoredProcedure;
adapter.InsertCommand = command;
SqlParameter param;
param = command.Parameters.Add("@columnID", SqlDbType.UniqueIdentifier);
* param.Value = new
Guid(table.Rows[index].ItemArray["ColumnName"].ToString());
}
}
}
Did I do something wrong that I am not seeing, or is there another way to
reference a column? 4 1884
Hi,
Just use
table.Rows[0]["ColumnName"].ToString()
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mike Collins" <Mi*********@discussions.microsoft.comwrote in message
news:25**********************************@microsof t.com...
This worked in the command window while in debug mode
?table.Rows[0].ItemArray["ColumnName"].ToString()
"f0165f94-648f-4997-b578-11d89c8b1f61"
But gives the error below when I compile.
Cannot implicitly convert type 'string' to 'int' and the word ColumnName
is
underlined.
Here is a code snippett (with error line marked with an asterisk):
DataSet ds = new DataSet();
ds.ReadXml(@"D:\Data\test.xml", XmlReadMode.ReadSchema);
foreach (DataTable table in ds.Tables)
{
for (int index = 0; index <= table.Rows.Count; index++)
{
{
SqlCommand command = new SqlCommand("ImportData", conn);
command.CommandType = CommandType.StoredProcedure;
adapter.InsertCommand = command;
SqlParameter param;
param = command.Parameters.Add("@columnID",
SqlDbType.UniqueIdentifier);
* param.Value = new
Guid(table.Rows[index].ItemArray["ColumnName"].ToString());
}
}
}
Did I do something wrong that I am not seeing, or is there another way to
reference a column?
Mike,
This should not have worked in the command window.
The reason it fails when you compile is because the ItemArray property
returns an array of values representing the row. Arrays are indexed on
integers, not strings, which is why you can't compile it.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Mike Collins" <Mi*********@discussions.microsoft.comwrote in message
news:25**********************************@microsof t.com...
This worked in the command window while in debug mode
?table.Rows[0].ItemArray["ColumnName"].ToString()
"f0165f94-648f-4997-b578-11d89c8b1f61"
But gives the error below when I compile.
Cannot implicitly convert type 'string' to 'int' and the word ColumnName
is
underlined.
Here is a code snippett (with error line marked with an asterisk):
DataSet ds = new DataSet();
ds.ReadXml(@"D:\Data\test.xml", XmlReadMode.ReadSchema);
foreach (DataTable table in ds.Tables)
{
for (int index = 0; index <= table.Rows.Count; index++)
{
{
SqlCommand command = new SqlCommand("ImportData", conn);
command.CommandType = CommandType.StoredProcedure;
adapter.InsertCommand = command;
SqlParameter param;
param = command.Parameters.Add("@columnID",
SqlDbType.UniqueIdentifier);
* param.Value = new
Guid(table.Rows[index].ItemArray["ColumnName"].ToString());
}
}
}
Did I do something wrong that I am not seeing, or is there another way to
reference a column?
That syntax works...thanks.
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
Just use
table.Rows[0]["ColumnName"].ToString()
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mike Collins" <Mi*********@discussions.microsoft.comwrote in message
news:25**********************************@microsof t.com...
This worked in the command window while in debug mode
?table.Rows[0].ItemArray["ColumnName"].ToString()
"f0165f94-648f-4997-b578-11d89c8b1f61"
But gives the error below when I compile.
Cannot implicitly convert type 'string' to 'int' and the word ColumnName
is
underlined.
Here is a code snippett (with error line marked with an asterisk):
DataSet ds = new DataSet();
ds.ReadXml(@"D:\Data\test.xml", XmlReadMode.ReadSchema);
foreach (DataTable table in ds.Tables)
{
for (int index = 0; index <= table.Rows.Count; index++)
{
{
SqlCommand command = new SqlCommand("ImportData", conn);
command.CommandType = CommandType.StoredProcedure;
adapter.InsertCommand = command;
SqlParameter param;
param = command.Parameters.Add("@columnID",
SqlDbType.UniqueIdentifier);
* param.Value = new
Guid(table.Rows[index].ItemArray["ColumnName"].ToString());
}
}
}
Did I do something wrong that I am not seeing, or is there another way to
reference a column?
Thanks, that helps a lot...especially in knowing why it did not work.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Mike,
This should not have worked in the command window.
The reason it fails when you compile is because the ItemArray property
returns an array of values representing the row. Arrays are indexed on
integers, not strings, which is why you can't compile it.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Mike Collins" <Mi*********@discussions.microsoft.comwrote in message
news:25**********************************@microsof t.com...
This worked in the command window while in debug mode
?table.Rows[0].ItemArray["ColumnName"].ToString()
"f0165f94-648f-4997-b578-11d89c8b1f61"
But gives the error below when I compile.
Cannot implicitly convert type 'string' to 'int' and the word ColumnName
is
underlined.
Here is a code snippett (with error line marked with an asterisk):
DataSet ds = new DataSet();
ds.ReadXml(@"D:\Data\test.xml", XmlReadMode.ReadSchema);
foreach (DataTable table in ds.Tables)
{
for (int index = 0; index <= table.Rows.Count; index++)
{
{
SqlCommand command = new SqlCommand("ImportData", conn);
command.CommandType = CommandType.StoredProcedure;
adapter.InsertCommand = command;
SqlParameter param;
param = command.Parameters.Add("@columnID",
SqlDbType.UniqueIdentifier);
* param.Value = new
Guid(table.Rows[index].ItemArray["ColumnName"].ToString());
}
}
}
Did I do something wrong that I am not seeing, or is there another way to
reference a column?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lauren Quantrell |
last post by:
I have a stored procedure using Convert where the exact same Convert
string works in the SELECT portion of the procedure but fails in the
WHERE portion.
The entire SP is listed below....
|
by: ET |
last post by:
I don't know whats the problem, but after I added functions
to first verify, then relink linked tables if not found,
now I can't convert that database to MDE format.
I can split the database, but...
|
by: simon |
last post by:
I have datetime variable:
Datetime tsEndTime;
Should I use (DateTime):
tsEndTime=(DateTime)rdr.GetValue(15)
or is better to use:
tsEndTime=Convert.ToDateTime(rdr.GetValue(15))
|
by: Andy Sutorius |
last post by:
Hi,
I am receiving the error when compiling the project, "cannot implicitly
convert type object to string".
The error points to this line of code and underlines the
dtrRecipient:...
|
by: Me |
last post by:
Hi all
I am getting a really bizzare error on when I convert a string into a
datetime:
The code is :
DateTime dt1 = Convert.ToDateTime("10 Sep 2005");
Console.WriteLine(dt1.Year);
|
by: compboy |
last post by:
Can anyone help me about this.
I have been trying all the ways I knew and I could find but just didnt
work.
I have tried:
using itoa but it says that it doesnt have that function.
and...
|
by: keliie |
last post by:
Hello (from Access novice),
I'm building a switchboard form (using a Treeview object). The treeview
is populated by two tables (tblSwitchboardParent and
tblSwitchboardChild). Within...
|
by: Shawn Ferguson |
last post by:
Hello All,
I'm trying to do what I would think would be simple and straightforward, but it is not. I have a 2 textbox on a form, a label, and a button, when I click the botton I want to add the...
|
by: Marco Nef |
last post by:
Hi there
I'm looking for a template class that converts the template argument to a
string, so something like the following should work:
Convert<float>::Get() == "float";
Convert<3>::Get() ==...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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...
| |