View Full Version : how is it in asp.net?
03-11-2007, 03:22 AM
as in asp, we used to create recordsets and then use it to call the database field names to get the value rite? the code is something like this :
set DBRecordset = Server.CreateObject("ADODB.Recordset")
DBRecordset.open SQLText, DBConnection, adOpenDynamic
val = DBRecordset("TableFieldName")
so how is it in asp.net? i just dunno the syntax...can someone guide me?? in desperate need of help now...thanking u all in advance...
03-11-2007, 05:49 AM
Wow you are going to be having fun. VB.net 2.0 is so much better then vbscript. I remember using my recordset to fill variables for display, inserts and update. But even back then I only used the recordset for display. All inserts, updates, and deletes I did with SQL statements.
But now you can databind you can use datagrids, and you also have the datareader. The datareader works a little like our recordset but it only reads oneway. No moving back and forward but I use the datareader kinda like I used the recordset. Like the code below, in it I am reading the information from the database into textboxs. I could just as easily be reading it into lables for display.
Dim reader As SqlDataReader
'Try to open database and read infromation.
reader = cmd.ExecuteReader()
'Fill the controls.
txtID.Text = reader("nameid").ToString()
firstName.Text = reader("first_name").ToString()
lastName.Text = reader("last_name").ToString()
Restriction.Text = reader("restriction").ToString()
Cost.Text = FormatCurrency(reader("cost"), 0).ToString()
Speed.Text = reader("speed").ToString()
address.Text = reader("address").ToString()
city.Text = reader("city").ToString()
state.Text = reader("state").ToString()
zip.Text = reader("zip").ToString()
lblResults.Text = ""
Catch err As Exception
lblResults.Text = "Error in reading information into text boxs. "
lblResults.Text &= err.Message
Get a good book and read it took me a while to make the conection on how asp.net OOP works. But once you get it you will see how much better and you will be able to do so much more with it.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.