SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Replacing value in column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rivo
Starting Member

Indonesia
3 Posts

Posted - 11/20/2013 :  03:03:20  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 11/20/2013 :  04:14:03  Show Profile  Reply with Quote
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

Indonesia
3 Posts

Posted - 11/20/2013 :  05:12:27  Show Profile  Reply with Quote
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

Edited by - rivo on 11/20/2013 05:13:11
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 11/20/2013 :  07:52:37  Show Profile  Reply with Quote
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

Indonesia
3 Posts

Posted - 11/21/2013 :  03:13:06  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 11/21/2013 :  06:55:51  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000