3
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by preethi_ga
0

Hi,

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

Regards
Veena

0

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?

0

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

0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.