A question in setting primary keys for a database  
Author Message
a. Nova





PostPosted: Visual Basic Express Edition, A question in setting primary keys for a database Top

Hi, I am currently handling a program which detects and deletes duplicated data records (data records identical in every or part of the fields). The original database does not have a primary key and I am also not supposed to add a primary key via Access or SQL Server. How can I add a primary key to the database such that I can perform modifications to the database Thanks for the reply.


Visual Studio Express Editions19  
 
 
Babak Izadi





PostPosted: Visual Basic Express Edition, A question in setting primary keys for a database Top

Hi there,

please clear your question

do you need to add a primary key to an existing table with filled data !

do you need a SQL statement that add a primary key to your table !

_______________________________________________
May the God blessings be.

LotraSoft Ltd.



 
 
a. Nova





PostPosted: Visual Basic Express Edition, A question in setting primary keys for a database Top

I need to add a primary key to an existing table with filled data. Thank you.

 
 
Babak Izadi





PostPosted: Visual Basic Express Edition, A question in setting primary keys for a database Top

Hi there,

you can execute this SQL Statement to do that :

ALTER TABLE YourTableName ADD NewFieldName INT IDENTITY Primary Key

You can change field data type to any other numeric values.

___________________________________________
May the God blessings be.

LotraSoft Ltd.



 
 
Bruno Yu - MSFT





PostPosted: Visual Basic Express Edition, A question in setting primary keys for a database Top

a.Nova,

First of all, please check whether you have the right too add a primary key with your current account. If not, please change your login account to the database.

Have you tried the Data Access Controls in VB.NET such as DataSet object You can use the SqlCommand object to insert or update in a database directly.

In the DataSet SqlCommand object, you can just execute the statement as is shown in the last post.

At last, please search the related contect in MSDN: http://msdn.microsoft.com