Re: Cannot access the added row using Table.Select method

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: RaviKiran (RaviKiran_at_discussions.microsoft.com)
Date: 10/04/04


Date: Sun, 3 Oct 2004 21:27:02 -0700

Hi Ryan ,
I am able to assign the values. If I see the values of the row values in the
quick watch window , it is showing me the latest value only(1001) , But If I
use the select method (1001) , it is not returning me the datarow, if I query
it with (850), it is returning me the data row which has value (1001 for
column 0)

 Primary Key of my table is an auto indexed column in my table.

Can u please suggest any other solution.

Regards,
RaviKiran

"W.G. Ryan eMVP" wrote:

> I think you may have a problem with assignment. Do you have Option Strict
> on by the way? I was having trouble doing a direct conversion of that code
> to C# but this code works fine and does essentially the same thing:
> DataTable dt = new DataTable();
>
> DataColumn dc = new DataColumn("BatchId", Type.GetType("System.Int32"));
>
> dt.Columns.Add(dc);
>
> DataRow dro = dt.NewRow();
>
> dt.Rows.Add(dro);
>
> dt.Rows[0][0] = "850";
>
> DataRow dro2 = dt.NewRow();
>
> dt.Rows.Add(dro2);
>
> dt.Rows[1][0] = "1000";
>
>
> //dv.Count = 0 here but if I change the values of R to ~ then I get 2
>
> dt.PrimaryKey = new DataColumn[] { dt.Columns["ValueName"] };
>
> DataRow[] dros = dt.Select("BatchId = '850'");
>
> dros[0][0] = "1001";
>
> DataRow[] dros2 = dt.Select("BatchId= '1001'");
>
> MessageBox.Show(dt.Rows[0][0].ToString()); //1001
>
>
> "RaviKiran" <RaviKiran@discussions.microsoft.com> wrote in message
> news:185F15B1-E2BB-4999-8CC6-973C043B07E2@microsoft.com...
> > Hi All,
> > I am working on a windows application. I am facing a problem in accessing
> > the added row of a table using Table.Select method.
> > Following explains the problem
> > Following is my table
> >
> > Table: BatchData
> > PrimaryKey : BatchId INT IDENTITY (AutoIndex Column)
> > I am accesing the table's data in a dataset with FillSchema and Fill ,and
> I
> > made the primarykey.readonly = false
> >
> > DS.Tables("BatchData").PrimaryKeyColumn.Readonly = false
> >
> > I am binding the part of the table to a DataGrid (Based on Selectction
> > criterion). I am adding the rows to the grid, which inturn adding rows to
> my
> > data table. I am able to access the added rows. Now I want to change the
> > primaryKey value of the added rows.I am able to assign the value to the
> > primary Key. When I am trying to access the row with the newly assigned
> > value, I am not able to retrieve the row.
> >
> > Following are the initial values
> >
> > DataRow dr = DS.Tables("BatchData").GetChanges(RowState.Added)(0)
> > dr("PrimaryKey") is 850 now -- Initial Value
> > I want to assign value - 10001 to the primary key
> > DS.Tables("BatchData").Select("BatchId = 850")(0)("BatchId") = 10001 --
> New
> > Value
> >
> > I am able to assign the value, Now I am trying to retrieve the row like
> the
> > following
> >
> > DS.Tables("BatchData").Select("BatchId = 10001")
> > Here I am facing the problem, I am not able to retrieve the row data if I
> > use the newly assigned value..
> >
> > Please help me in solving this problem..
> >
> >
> > Regards,
> > RaviKiran
> >
> >
> >
> >
> >
>
>
>



Relevant Pages

  • Cannot access the added row using Table.Select method
    ... I am working on a windows application. ... I want to assign value - 10001 to the primary key ... I am able to assign the value, Now I am trying to retrieve the row like the ... Here I am facing the problem, I am not able to retrieve the row data if I ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Cannot access the added row using Table.Select method
    ... I think you may have a problem with assignment. ... > primary Key. ... I am not able to retrieve the row. ... > Here I am facing the problem, I am not able to retrieve the row data if I ...
    (microsoft.public.dotnet.framework.adonet)
  • ASP.net DataGrid with LinkButton
    ... That primary key will be either a textbox or it can be a ... this primary key value into a standard select statement to retrieve uploaded ... another table of the database along with the previously viewed file. ... suspect this is a simple download from one table to another in the database. ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: DBI & primary keys
    ... > retrieve the unique primary key that's created automatically by the db as ... > to want to know the primary key for a newly inserted record, ... "You can retrieve the most recent AUTO_INCREMENT value with the LAST_INSERT_IDSQL function" ...
    (comp.lang.perl.misc)
  • Re: copy auto_increment value to another field
    ... it seems that that prefix is quite redundant. ... could easily use the auto_increment primary key value, ... kudos as a prefixed string, ... retrieve the id value and add it into another field, ...
    (comp.lang.php)