Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Replacing value in column

Author  Topic 

rivo
Starting Member

3 Posts

Posted - 2013-11-20 : 03:03:20
Hi,

I want to replace the value in a column with the content from listbox.

I have wrote the code like,

Dim i as Integer
dim sql as string
For i = 0 to Customerslist1.ListCount-1
sql = "UPDATE master (gstl) VALUES(" +chrb(34)+Customerslist1.Cell(i,8)+chrb(34)+")"
app.Gudangstock.SQLExecute(sql)
app.Gudangstock.commit
next
msgbox"insert ok"
UpdateCustomerList1

but no error found and the sql command is not executing.

Any Help.?

Thanks

Regards,
Rivo

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-20 : 04:14:03
the sql statement should be


"UPDATE master SET gstl = " +chrb(34)+Customerslist1.Cell(i,8)+chrb(34)

Assuming your table name being master and columnname gstl

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

rivo
Starting Member

3 Posts

Posted - 2013-11-20 : 05:12:27
Thanks..
Its work.. but way slower to update the record.
Is there any other faster way, to write specific data in a column into database.?

thanks
Rivo
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-20 : 07:52:37
the above statement updates all rows in table. so based on size of table it will take good amount of time. DO you've any conditions using which you can identify specific rows to update?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

rivo
Starting Member

3 Posts

Posted - 2013-11-21 : 03:13:06
The database is generating ID as integer value.
is it possible to based the condition from that?

thanks
Rivo
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-21 : 06:55:51
tell us what your exact requirement is. do you want to add sequentail value to table column?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -