FindByPrimaryKey(keyID) returns null

  • Thread starter Thread starter Nime
  • Start date Start date
N

Nime

I use a dataset and autogenerated logic codes.
VS2005 generated FindByPrimaryKey method but the method
returns null instead of the related row even ý use a valid key.
The lines are below:

//DataTable
DataSetOrganizasyon.tableGeziDataTable tblGeziDT = new
DataSetOrganizasyon.tblGeziDataTable();

//DataTableAdapter
DataSetOrganizasyonTableAdapters.tblGeziTableAdapter tblGeziTA = new
Organizasyon.strDataSetOrganizasyonTableAdapters.tblGeziTableAdapter();

tblGeziRow = tblGeziDT.FindBygeziID(intAktifOrganizasyonID);

Now I cannot load the data...

Autogenerated lines are below:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public tblGeziRow NewtblGeziRow() {
return ((tblGeziRow)(this.NewRow()));
}
 
I think it doesn't attemp to read the row from the DB and just load the data
from
datatable object..... And I should load the data from the sql server...
 
Related sample is here:
http://msdn2.microsoft.com/en-us/library/y06xa2h1(vs.80).aspx

I'm not sure hot to load the data by primary key...

haber iletisinde þunlarý said:
I think it doesn't attemp to read the row from the DB and just load the
data from
datatable object..... And I should load the data from the sql server...



haber iletisinde þunlarý said:
I use a dataset and autogenerated logic codes.
VS2005 generated FindByPrimaryKey method but the method
returns null instead of the related row even ý use a valid key.
The lines are below:

//DataTable
DataSetOrganizasyon.tableGeziDataTable tblGeziDT = new
DataSetOrganizasyon.tblGeziDataTable();

//DataTableAdapter
DataSetOrganizasyonTableAdapters.tblGeziTableAdapter tblGeziTA = new

Organizasyon.strDataSetOrganizasyonTableAdapters.tblGeziTableAdapter();

tblGeziRow = tblGeziDT.FindBygeziID(intAktifOrganizasyonID);

Now I cannot load the data...

Autogenerated lines are below:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public tblGeziRow NewtblGeziRow() {
return ((tblGeziRow)(this.NewRow()));
}
 
Nime,

Well, you are calling FindBygezID on an empty data table. You need to
use the data adapter you created to populate the data table, or add rows
yourself.

Hope this helps.
 
THANK YOU A LOT : ) NOW I CAN SEE THE ROW!
tblGeziTA.Fill(tblGeziDT); //I'VE ADDED THIS LINE

tblGeziRow = tblGeziDT.FindBygeziID(intAktifOrganizasyonID);





haber said:
Nime,

Well, you are calling FindBygezID on an empty data table. You need to
use the data adapter you created to populate the data table, or add rows
yourself.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Nime said:
I use a dataset and autogenerated logic codes.
VS2005 generated FindByPrimaryKey method but the method
returns null instead of the related row even ý use a valid key.
The lines are below:

//DataTable
DataSetOrganizasyon.tableGeziDataTable tblGeziDT = new
DataSetOrganizasyon.tblGeziDataTable();

//DataTableAdapter
DataSetOrganizasyonTableAdapters.tblGeziTableAdapter tblGeziTA = new

Organizasyon.strDataSetOrganizasyonTableAdapters.tblGeziTableAdapter();

tblGeziRow = tblGeziDT.FindBygeziID(intAktifOrganizasyonID);

Now I cannot load the data...

Autogenerated lines are below:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public tblGeziRow NewtblGeziRow() {
return ((tblGeziRow)(this.NewRow()));
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top