Is there any way to create a new column in a dataset table from 2 string
column and a int column? I got an error "expecting string" from my code
below. Any help would be appreciated.
DataColumn scc1 = new
DataColumn("CodeLength",Type.GetType("System.Strin g"));
scc1.Expression = "iif(len(CycleLength) > 0,CycleCode + ' - ' +
CycleLength,CycleCode)";
dsSchTables.Tables["ServiceCycle"].Columns.Add(scc1);
dsSchTables.AcceptChanges();
DataColumn scc2 = new
DataColumn("CodeLengthUnit",Type.GetType("System.S tring"));
scc1.Expression = "iif(len(CycleUnit) > 0,CodeLength + ' - ' +
CycleUnit,CodeLength)";
dsSchTables.Tables["ServiceCycle"].Columns.Add(scc2);
dsSchTables.AcceptChanges(); 5 1357
Alpha,
I am curious about the meaning of the + '-' + in your expression?
Cor
"Alpha" <Al***@discussions.microsoft.com> schreef in bericht
news:97**********************************@microsof t.com... Is there any way to create a new column in a dataset table from 2 string column and a int column? I got an error "expecting string" from my code below. Any help would be appreciated.
DataColumn scc1 = new DataColumn("CodeLength",Type.GetType("System.Strin g")); scc1.Expression = "iif(len(CycleLength) > 0,CycleCode + ' - ' + CycleLength,CycleCode)"; dsSchTables.Tables["ServiceCycle"].Columns.Add(scc1); dsSchTables.AcceptChanges();
DataColumn scc2 = new DataColumn("CodeLengthUnit",Type.GetType("System.S tring")); scc1.Expression = "iif(len(CycleUnit) > 0,CodeLength + ' - ' + CycleUnit,CodeLength)"; dsSchTables.Tables["ServiceCycle"].Columns.Add(scc2); dsSchTables.AcceptChanges();
That is just part of the string that I would like to display to the user to
make it easier to read the information that are consist of a Code, followed
by a '_' and the the length and unit. It would read something like this in
the combox 3k - 3000 miles
"Cor Ligthert [MVP]" wrote: Alpha,
I am curious about the meaning of the + '-' + in your expression?
Cor
"Alpha" <Al***@discussions.microsoft.com> schreef in bericht news:97**********************************@microsof t.com... Is there any way to create a new column in a dataset table from 2 string column and a int column? I got an error "expecting string" from my code below. Any help would be appreciated.
DataColumn scc1 = new DataColumn("CodeLength",Type.GetType("System.Strin g")); scc1.Expression = "iif(len(CycleLength) > 0,CycleCode + ' - ' + CycleLength,CycleCode)"; dsSchTables.Tables["ServiceCycle"].Columns.Add(scc1); dsSchTables.AcceptChanges();
DataColumn scc2 = new DataColumn("CodeLengthUnit",Type.GetType("System.S tring")); scc1.Expression = "iif(len(CycleUnit) > 0,CodeLength + ' - ' + CycleUnit,CodeLength)"; dsSchTables.Tables["ServiceCycle"].Columns.Add(scc2); dsSchTables.AcceptChanges();
Alpha,
I don't know it, however how would the expression know that it is a
concatination if you use a system.Int32 and a system.string.
If the problem is that your first operand is an integer, than you can maybe
try the trick to add in advance a '' + (double single quote) .
Just a try and a guess
Cor
Can I fill a dataset table with a SQL SERVER View? That way I can easily
concatenate an cast the int type to string and form a column that way. What
would the sytax be if I can fill with View? I only know so far to do SQL
select from table with Select command object.
Thanks, Alpha
"Cor Ligthert [MVP]" wrote: Alpha,
I don't know it, however how would the expression know that it is a concatination if you use a system.Int32 and a system.string.
If the problem is that your first operand is an integer, than you can maybe try the trick to add in advance a '' + (double single quote) .
Just a try and a guess
Cor
I created a view in SQL SERVER and I fill the dataset by selecting the
concatenated column from the view and it works. Thanks, Alpha
"Alpha" wrote: Can I fill a dataset table with a SQL SERVER View? That way I can easily concatenate an cast the int type to string and form a column that way. What would the sytax be if I can fill with View? I only know so far to do SQL select from table with Select command object.
Thanks, Alpha
"Cor Ligthert [MVP]" wrote:
Alpha,
I don't know it, however how would the expression know that it is a concatination if you use a system.Int32 and a system.string.
If the problem is that your first operand is an integer, than you can maybe try the trick to add in advance a '' + (double single quote) .
Just a try and a guess
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Milo Woodward |
last post by:
I have some columns of data in SQL server that are of NVARCHAR(420)
format but they are dates. The dates are in DD/MM/YY format. I want to
be able to convert them to our accounting system format...
|
by: Philip Sherman |
last post by:
I'm trying to copy production statistics to a test database and can't
set the column statistics for a VARGRAPHIC column to match what RUNSTATS
generated on production.
The reason code and some...
|
by: nimdez |
last post by:
Hi,
I am working on an existing code base in which a lot of data displayed
to the user is formatted in tables. Most tables are printed row-by-row
using printf() with "%s" print conversion...
|
by: Daniel M. |
last post by:
I have a query that gets a string column containing a date, ex. 20040825.
If I use the property builder to format the string to 08/25/2004 it does not
work because it only accepts datetime columns....
|
by: PeterZ |
last post by:
Hi,
In a running C# app with a datagrid control I select all rows in the
dataGrid using CTRL-A, I then paste into some other app like notepad or Word
but the column headings get left off.
Is...
|
by: Bob Day |
last post by:
VS 2003, sql
How do you determine the data type of a column if its value is DBNull?
1)Table:
Column1 STRING non-nullable
2) Fill to a DataSet via DataAdapter
3) dim Data_Type_Is...
|
by: Coen |
last post by:
I have a datagrid bound to a dataset's table. I'm using a tablestyle and so I
can, with the column.format property, format numeric and date typed
datacolumns. But I need to format a column of type...
|
by: =?Utf-8?B?QmFidU1hbg==?= |
last post by:
Hi,
I have a GridView and a SqlDataSource controls on a page. The SqlDataSource
object uses stored procedures to do the CRUD operations. The DataSource has
three columns one of which -...
|
by: Ken |
last post by:
I'm trying to run a loop to capture column property information from a
table in my datasource. Can anybody see where this is going wrong?
Dim tbl As New DataTable
Dim col As DataColumn
Dim x...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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: 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,...
|
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: 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,...
| |