hi, when i update records in VB, only 0's are stored in database, can anyone halp me to solve this? send me appropriate code for this?

Hi,

Can you Post your code (Saving Part) here..? so that somebody can point out the problem...

Regards
Veena

hi ,
I am using VB and SQL Server as backend. and my coding is .... follows..
[ dim con as connection ]
[dim rst as recordset ]
In page load,
[ set con = new connection ]
[ set rst = new recordset ]
[ con.open " provider=SQLOLEDB;initialcatalog=preethi;database=ACER;integrated security=sspi]
' preethi -> database name, ACER -> server name
[ rst.open"select * from tablename",adOpenkeyset,adLockOptimistic ]
[ rst.activeconnection = con ]
[ loadcontrols ]

Im using a button for adding new records and i have named the button as Addnew.
in that button click event the coding is...
[ clearcontrols ]
[rst.addnew ]
[ loadrecords ]
[rst.update ]

loadrecords is a private fuction,
[rst!fieldname1=val(text1.text) ]
[ rst!fieldname2=val(text2.text) ]

clearcontrols is also private function,
[text1.text = " " ]
[text2.text = " " ]

private sub loadcontrols()
[ text1.text = rst!fieldname1 ]
[ text2.text = rst!fieldname2 ]

And also i have Update button, in that update-click event i have the following coding,
[cmdupdate.default=true]
[ rst.update ]

So if i update records, only 0's are stored in database. so can u help me to solve this?

Hi,
Actually in AddNew button, you just give

[ clearcontrols ]
[rst.addnew ]
[ loadrecords ]
[rst.update ]

replace it as

clearcontrols
   rst.AddNew

and if the user press UpdateButton then u save the record, that is

loadrecords
 rst.Update

instead of

[cmdupdate.default=true]
[ rst.update ]

Mistake
You are given that when user press AddNew it will create a new record without getting the input and it updates to the table. Then if click Update button, 0 will be updated. because u are not using loadrecords function in Update Button

Hi,

I guess, your Field1 and 2 in table are of string/text type, and you are saving Val(text1.text)....?
Val() functions converts the text value to string..
So change the Load records like this :

rst!fieldname1=text1.text
rst!fieldname2=text2.text

also check Selva's points above..

Regards
Veena

hi,
I think your tips will be help full to me. thanks for your responces. I will try it out and then i will get you back if again any problem occurs.
bye.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.