Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Long time reader, first time poster! ;)

I've been programming for a long long time, machine code, assembler, basic, fortran, rpg you name it, now revisiting vb.net because of issues with vb6... and so far my experience with .net is .... well .... beyond description!

Hope someone can give me a few pointers and save what few hairs i have left!

In vb6 I used to do something to the effect of:
VB
with rs '(recordset = sql is essentially 'Select * from table')
  while not .eof
    if .field("whatever")="something"
      .field("whatever")="something else"
      .update
    end if
   .movenext
wend


The code above (through stripped down) used to run through every record in a table and allow me to run checks on various fields, make corrections if needed and move on to the next record. From what i've seen in .net updates are done via sql statements which in my case would require a ton more coding ... my hope is there is another way to do this... yes?
Posted
Comments
CHill60 20-Jun-13 20:43pm    
Yes. DotNet stuff is on the whole more efficient than VB6 (trust me ... I *know* VB6). You can still run through every record in a table and do stuff then move on to the next record. Updates in VB6 *had* to be done via sql statements if you wanted to update a sql table. No Change. You will not require a "ton" more coding. What is your "real" question here?

{Edit} Have a look here http://www.dreamincode.net/forums/topic/32392-sql-basics-in-vbnet/[^]

1 solution

Well that was the question, what's the best way to do this (sample code would help or a pointer in a direction).
Everything i've checked online requires an sql statement as below...
SQL
cmd = New SqlCommand("INSERT INTO Options([Field1],[Field2],[Field3]) Values (@Field1, @Field2, @Field3)")
cmd.Connection = db.conn
With cmd.Parameters
    .AddWithValue("@Field1", Field1)
    .AddWithValue("@Field2", Field2)
    .AddWithValue("@Field3", Field3)
End With


The code above is what i was referring to in my original statement 'updates require an sql statement' ....

Also, Thanks for the link, looking at it now (and will take a bit to go through) but believe it is essentially the same as i've seen everywhere. One or the other, not all in a single place like my original code.
----------------------------------------------------------------------------------------------
Updated: Just checked out the page/code samples, according to the code it's called Inline sql.
After a 'quick' view, the code functions given are pretty much useless as they are hard coded to the number of fields passed, to me, you would need to code a function for each table and every possible combination (or pass an array)

If this is the most streamlined coding for what I need to do, pretty much explains all the issues with M$ products the exponential increase in size and resource required!

But do appreciate the quick reply and the pointer to the sample code!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900