Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: how is it in asp.net?
03-11-2007, 03:22 AM #1
- Join Date
- Feb 2004
- Thanked 0 Times in 0 Posts
how is it in asp.net?
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 :
Dim val set DBRecordset = Server.CreateObject("ADODB.Recordset") DBRecordset.open SQLText, DBConnection, adOpenDynamic val = DBRecordset("TableFieldName")Warm Regards,
03-11-2007, 05:49 AM #2
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. Try con.Open() reader = cmd.ExecuteReader() reader.Read() '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() reader.Close() lblResults.Text = "" Catch err As Exception lblResults.Text = "Error in reading information into text boxs. " lblResults.Text &= err.Message Finally con.Close() End Try