Edit SQL table

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

Hi all,

If I want to add rows to an SQL table, can I only do it like this:

Dim commd As SqlCommand = New SqlCommand("insert into table etc....")

Or is there a better way?


Additionally, is there a best pratice method for connecting to SQL and
editing tables? When I google there are just soooo many different ways
of doing it!
 
Hi all,

If I want to add rows to an SQL table, can I only do it like this:

Dim commd As SqlCommand = New SqlCommand("insert into table etc....")

Or is there a better way?

Take a look at SQL Parameters - they help protect code and simplify your
SQl statements.

Another thing - take a look at Microsoft's Data Application Block (v2 or
v3), it'll help simplify your SQL code.
 
Daniel,

What do you mean with "better". In my opinion are those thousands methods
not made for nothing.

If you need a table with only one row, than I surely advise you the method
you are using now and have absolute no better option.

Cor
 
Cor said:
Daniel,

What do you mean with "better". In my opinion are those thousands methods
not made for nothing.

If you need a table with only one row, than I surely advise you the method
you are using now and have absolute no better option.

Cor

Thanks, I have a table and i might be adding 50,000 rows. The app runs
as a service so this is all done in memory rather than a user using a
datagrid. so is my method still OK for this or is there a much faster
one? (like maybe create the entire table in memory and the send it all
at once to the server perhaps?????)
 
Daniel,

I would absolute for what you tell use the one you are using now.

Assuming it is everytime inserting physical at the end and no updates or
what ever.

I hope this helps,

Cor
 
Cor said:
Daniel,

I would absolute for what you tell use the one you are using now.

Assuming it is everytime inserting physical at the end and no updates or
what ever.

I hope this helps,

Cor
Great, then i'll stick with the existing code. And if I wanted to
update an existing record would I still use this method...?
 
Daniel,

Probably yes, are you sure that this program is the only one who does add
and update, otherwise you have to catch the concurrency errors.

And than of course an update command and not an Insert.

Cor
 
Cor said:
Daniel,

Probably yes, are you sure that this program is the only one who does add
and update, otherwise you have to catch the concurrency errors.

And than of course an update command and not an Insert.

Cor
OK thanks.
 

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