Detailsview - how do I add the first record?

J

JonBosker

Help...

I have a brand new database table and I open the page that has a
DetailsView control that is bound to that table it does not show
anything - not even a new button - so how can I add the first
record??

The reason I ask is because I have a generic page that will display
data from any table. Therefore I cannot add the row programmatically
-
I have tried adding blank values (by querying the SQL Server schema
(SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME = MyTable) but that does not work if the table has foreign
key constraints etc..

Any ideas?

Thanks in advance,
Jon

dbgurus.com.au
 
G

Guest

Help...

I have a brand new database table and I open the page that has a
DetailsView control that is bound to that table it does not show
anything - not even a new button - so how can I add the first
record??

The reason I ask is because I have a generic page that will display
data from any table. Therefore I cannot add the row programmatically
-
I have tried adding blank values (by querying the SQL Server schema
(SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME = MyTable) but that does not work if the table has foreign
key constraints etc..

SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME = MyTable

will return you result when it exists.

That is you have to insert the row into COLUMNS before.

For example (abstract)

if (table_has_no_rows)
{
insert_row();
} else {
get_rows();
}
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top