freelanceprogrammers.org Forum Index » ASP
Accessing a record and the field values.
Joined: 03 Jan 2005
Posts: 15
Accessing a record and the field values.
In aspclassic I got each field in a recordset and assigned it`s value to a
variable. EASY. How can I accomplish the same thing in ADO.NET .... Ive been
trying and I can`t get it working.
How I did it in ADO... Below.............................
> `create a SQL statement open the recordset
> Dim strSQL
> strSQL = "SELECT * FROM tblBTC"
>
> Dim objRS
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objRS.Open strSQL, objConn
>
>
> `FIND THE RECORD WE WANT
> Dim strShowRecord
>
> Do While Not (objRS.EOF OR strShowRecord)
> If Not(StrComp(objRS("PlayingName"), strRecord, vbTextCompare) = 0)
> Then
> `nothing
> objRS.MoveNext
> Else
> strShowRecord = true
> End If
> Loop
>
>
>
> Dim strName, strPlayingname, strUserName, strPassword, strLocation,
> strEmail, strAge, strIcq, strAim, strOccupation
> Dim strBio, strPersonalInformation, strGamesPlayed, strConnect,
> strProcessor, strRam, strVideocard
> Dim strSoundcard, strHarddrive, strAdditionalsysteminformation, strPhoto,
> strSystemPhoto, strDateJoined, strOS
>
> strName = objRS("Name")
> strPlayingname = objRS("Playingname")
> strUserName = objRS("UserName")
> strPassword = objRS("Password")
> strLocation = objRS("Location")
> strEmail = objRS("Email")
> strAge = objRS("Age")
> strIcq = objRS("Icq")
> strAim = objRS("Aim")
> strOccupation = objRS("Occupation")
> strBio = objRS("Bio")
> strPersonalInformation = objRS("PersonalInformation")
> strGamesPlayed = objRS("GamesPlayed")
> strConnect = objRS("Connect")
> strProcessor = objRS("Processor")
> strRam = objRS("Ram")
> strVideocard = objRS("Videocard")
> strSoundcard = objRS("Soundcard")
> strHarddrive = objRS("Harddrive")
> strAdditionalsysteminformation = objRS("Additionalsysteminformation")
> strPhoto = objRS("Photo")
> strSystemPhoto = objRS("SystemPhoto")
> strDateJoined = objRS("DateJoined")
> strOS = objRS("OS")
ADO.NET I have so far........... Probalby way off.............
Ive tried a lot and commented a bunch of lines that didnt work
etc.....................
`Open the Connection -------------------------------------
Dim objConn As OleDbConnection
Dim objConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:InetpubwwwroottcNETDBelcherman.mdb"
objConn = New OleDb.OleDbConnection(objConnString)
objConn.Open()
`Response.Write("Connection OPENED <BR><BR>")
`Open the Connection -------------------------------------
`Create a DataSet ----------------------------------------
Dim objDataSet As New DataSet
`Response.Write("objDataSet Created <BR><BR>")
`Create a DataSet ----------------------------------------
`---------- Get Playingname from Querystring ------
Dim strPlayingName As String
strPlayingName = Request.QueryString("PlayingName")
Dim strSQLstring As String
strSQLstring = "SELECT * FROM tblBTC WHERE PlayingName LIKE `" &
strPlayingName & "`"
`--------------------------------
`Create a DataAdapter ------------------------------------
Dim objDataAdapter As OleDbDataAdapter
`objDataAdapter = New OleDbDataAdapter("SELECT * FROM tblBTC", objConn)
objDataAdapter = New OleDbDataAdapter(strSQLstring, objConn)
objDataAdapter.Fill(objDataSet, "BTC MEMBERS")
`Response.Write("objDataAdapter Created and used to fill the the objDataSet
with tblBTC <BR><BR>")
`Create a DataAdapter ------------------------------------
`CODE ===============================================================
`tblBTC.DataSource = objDataSet
`tblBTC.DataBind()
`literal1.text = " HTML CODE "
`Want to add more:
`literal1.text &= " MORE HTML CODE "
`<%# DataBinder.Eval(Container.DataItem, "PlayingName") %>
Dim tblBTC As DataTable = objDataSet.Tables.Item("tblBTC")
`tblBTC.Rows.Item("PlayingName")
Dim strTEST As String
`strTEST = tblBTC.Columns("PlayingName").
`strTEST = objDataSet.Tables("tblBTC").Rows.Item("PlayingName").ToString()
` Iterate through the rows.
`Dim tblBTCDataRow As DataRow
`For Each tblBTCDataRow In tblBTC.Rows
`Console.WriteLine(tblBTCDataRow(0))
`Next
`Dim column As DataColumn = dt.Columns("Description")
`Dim tblBTCDataRow As DataRow = tblBTC.Rows(0)
Joined: 07 Jan 2006
Posts: 63
Accessing a record and the field values.
DataReaders or DataTables.
http://www.learnasp.com/freebook/learn/datareader.aspx
http://www.learnasp.com/freebook/learn/datatable.aspx
Variables with or wthout stringbuilders or Literals whatever floats your boat:
http://www.learnasp.com/freebook/learn/literalsrock.aspx
On Wed, 5 Jan 2005 21:49:06 -0500,
System-Administrator@...
<System-Administrator@...> wrote:
> In aspclassic I got each field in a recordset and assigned it`s value to a
> variable. EASY. How can I accomplish the same thing in ADO.NET .... Ive
> been
> trying and I can`t get it working.
>
> How I did it in ADO... Below.............................
>
>
> > `create a SQL statement open the recordset
> > Dim strSQL
> > strSQL = "SELECT * FROM tblBTC"
> >
> > Dim objRS
> > Set objRS = Server.CreateObject("ADODB.Recordset")
> > objRS.Open strSQL, objConn
> >
> >
> > `FIND THE RECORD WE WANT
> > Dim strShowRecord
> >
> > Do While Not (objRS.EOF OR strShowRecord)
> > If Not(StrComp(objRS("PlayingName"), strRecord, vbTextCompare) = 0)
> > Then
> > `nothing
> > objRS.MoveNext
> > Else
> > strShowRecord = true
> > End If
> > Loop
> >
> >
> >
> > Dim strName, strPlayingname, strUserName, strPassword, strLocation,
> > strEmail, strAge, strIcq, strAim, strOccupation
> > Dim strBio, strPersonalInformation, strGamesPlayed, strConnect,
> > strProcessor, strRam, strVideocard
> > Dim strSoundcard, strHarddrive, strAdditionalsysteminformation,
> strPhoto,
> > strSystemPhoto, strDateJoined, strOS
> >
> > strName = objRS("Name")
> > strPlayingname = objRS("Playingname")
> > strUserName = objRS("UserName")
> > strPassword = objRS("Password")
> > strLocation = objRS("Location")
> > strEmail = objRS("Email")
> > strAge = objRS("Age")
> > strIcq = objRS("Icq")
> > strAim = objRS("Aim")
> > strOccupation = objRS("Occupation")
> > strBio = objRS("Bio")
> > strPersonalInformation = objRS("PersonalInformation")
> > strGamesPlayed = objRS("GamesPlayed")
> > strConnect = objRS("Connect")
> > strProcessor = objRS("Processor")
> > strRam = objRS("Ram")
> > strVideocard = objRS("Videocard")
> > strSoundcard = objRS("Soundcard")
> > strHarddrive = objRS("Harddrive")
> > strAdditionalsysteminformation = objRS("Additionalsysteminformation")
> > strPhoto = objRS("Photo")
> > strSystemPhoto = objRS("SystemPhoto")
> > strDateJoined = objRS("DateJoined")
> > strOS = objRS("OS")
>
>
>
> ADO.NET I have so far........... Probalby way off.............
> Ive tried a lot and commented a bunch of lines that didnt work
> etc.....................
>
>
>
> `Open the Connection -------------------------------------
>
> Dim objConn As OleDbConnection
>
> Dim objConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=C:InetpubwwwroottcNETDBelcherman.mdb"
>
> objConn = New OleDb.OleDbConnection(objConnString)
>
> objConn.Open()
>
> `Response.Write("Connection OPENED <BR><BR>")
>
> `Open the Connection -------------------------------------
>
>
>
> `Create a DataSet ----------------------------------------
>
> Dim objDataSet As New DataSet
>
> `Response.Write("objDataSet Created <BR><BR>")
>
> `Create a DataSet ----------------------------------------
>
> `---------- Get Playingname from Querystring ------
>
> Dim strPlayingName As String
>
> strPlayingName = Request.QueryString("PlayingName")
>
>
>
> Dim strSQLstring As String
>
> strSQLstring = "SELECT * FROM tblBTC WHERE PlayingName LIKE `" &
> strPlayingName & "`"
>
> `--------------------------------
>
>
>
> `Create a DataAdapter ------------------------------------
>
> Dim objDataAdapter As OleDbDataAdapter
>
> `objDataAdapter = New OleDbDataAdapter("SELECT * FROM tblBTC", objConn)
>
> objDataAdapter = New OleDbDataAdapter(strSQLstring, objConn)
>
> objDataAdapter.Fill(objDataSet, "BTC MEMBERS")
>
> `Response.Write("objDataAdapter Created and used to fill the the objDataSet
> with tblBTC <BR><BR>")
>
> `Create a DataAdapter ------------------------------------
>
>
>
>
>
> `CODE ===============================================================
>
> `tblBTC.DataSource = objDataSet
>
> `tblBTC.DataBind()
>
> `literal1.text = " HTML CODE "
>
> `Want to add more:
>
> `literal1.text &= " MORE HTML CODE "
>
> `<%# DataBinder.Eval(Container.DataItem, "PlayingName") %>
>
>
>
>
>
>
>
>
>
>
>
> Dim tblBTC As DataTable = objDataSet.Tables.Item("tblBTC")
>
> `tblBTC.Rows.Item("PlayingName")
>
> Dim strTEST As String
>
> `strTEST = tblBTC.Columns("PlayingName").
>
> `strTEST = objDataSet.Tables("tblBTC").Rows.Item("PlayingName").ToString()
>
> ` Iterate through the rows.
>
> `Dim tblBTCDataRow As DataRow
>
> `For Each tblBTCDataRow In tblBTC.Rows
>
> `Console.WriteLine(tblBTCDataRow(0))
>
> `Next
>
>
>
> `Dim column As DataColumn = dt.Columns("Description")
>
> `Dim tblBTCDataRow As DataRow = tblBTC.Rows(0)
>
>
>
> ________________________________
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
>
> To unsubscribe from this group, send an email to:
> AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Joined: 10 Jan 2006
Posts: 12
Accessing a record and the field values.
What you want in a simple example:
http://www.aspnet101.com/aspnet101/aspnet/codesample.aspx?code=drtest2
-----Original Message-----
From: System-Administrator@...
[mailto:System-Administrator@...]
Sent: donderdag 6 januari 2005 3:49
To: AspNetAnyQuestionIsOk@yahoogroups.com
Subject: [AspNetAnyQuestionIsOk] Accessing a record and the field values.
In aspclassic I got each field in a recordset and assigned it`s value to a
variable. EASY. How can I accomplish the same thing in ADO.NET .... Ive been
trying and I can`t get it working.
How I did it in ADO... Below.............................
> `create a SQL statement open the recordset
> Dim strSQL
> strSQL = "SELECT * FROM tblBTC"
>
> Dim objRS
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objRS.Open strSQL, objConn
>
>
> `FIND THE RECORD WE WANT
> Dim strShowRecord
>
> Do While Not (objRS.EOF OR strShowRecord)
> If Not(StrComp(objRS("PlayingName"), strRecord, vbTextCompare) = 0)
> Then
> `nothing
> objRS.MoveNext
> Else
> strShowRecord = true
> End If
> Loop
>
>
>
> Dim strName, strPlayingname, strUserName, strPassword, strLocation,
> strEmail, strAge, strIcq, strAim, strOccupation
> Dim strBio, strPersonalInformation, strGamesPlayed, strConnect,
> strProcessor, strRam, strVideocard
> Dim strSoundcard, strHarddrive, strAdditionalsysteminformation, strPhoto,
> strSystemPhoto, strDateJoined, strOS
>
> strName = objRS("Name")
> strPlayingname = objRS("Playingname")
> strUserName = objRS("UserName")
> strPassword = objRS("Password")
> strLocation = objRS("Location")
> strEmail = objRS("Email")
> strAge = objRS("Age")
> strIcq = objRS("Icq")
> strAim = objRS("Aim")
> strOccupation = objRS("Occupation")
> strBio = objRS("Bio")
> strPersonalInformation = objRS("PersonalInformation")
> strGamesPlayed = objRS("GamesPlayed")
> strConnect = objRS("Connect")
> strProcessor = objRS("Processor")
> strRam = objRS("Ram")
> strVideocard = objRS("Videocard")
> strSoundcard = objRS("Soundcard")
> strHarddrive = objRS("Harddrive")
> strAdditionalsysteminformation = objRS("Additionalsysteminformation")
> strPhoto = objRS("Photo")
> strSystemPhoto = objRS("SystemPhoto")
> strDateJoined = objRS("DateJoined")
> strOS = objRS("OS")
ADO.NET I have so far........... Probalby way off.............
Ive tried a lot and commented a bunch of lines that didnt work
etc.....................
`Open the Connection -------------------------------------
Dim objConn As OleDbConnection
Dim objConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:InetpubwwwroottcNETDBelcherman.mdb"
objConn = New OleDb.OleDbConnection(objConnString)
objConn.Open()
`Response.Write("Connection OPENED <BR><BR>")
`Open the Connection -------------------------------------
`Create a DataSet ----------------------------------------
Dim objDataSet As New DataSet
`Response.Write("objDataSet Created <BR><BR>")
`Create a DataSet ----------------------------------------
`---------- Get Playingname from Querystring ------
Dim strPlayingName As String
strPlayingName = Request.QueryString("PlayingName")
Dim strSQLstring As String
strSQLstring = "SELECT * FROM tblBTC WHERE PlayingName LIKE `" &
strPlayingName & "`"
`--------------------------------
`Create a DataAdapter ------------------------------------
Dim objDataAdapter As OleDbDataAdapter
`objDataAdapter = New OleDbDataAdapter("SELECT * FROM tblBTC", objConn)
objDataAdapter = New OleDbDataAdapter(strSQLstring, objConn)
objDataAdapter.Fill(objDataSet, "BTC MEMBERS")
`Response.Write("objDataAdapter Created and used to fill the the objDataSet
with tblBTC <BR><BR>")
`Create a DataAdapter ------------------------------------
`CODE ===============================================================
`tblBTC.DataSource = objDataSet
`tblBTC.DataBind()
`literal1.text = " HTML CODE "
`Want to add more:
`literal1.text &= " MORE HTML CODE "
`<%# DataBinder.Eval(Container.DataItem, "PlayingName") %>
Dim tblBTC As DataTable = objDataSet.Tables.Item("tblBTC")
`tblBTC.Rows.Item("PlayingName")
Dim strTEST As String
`strTEST = tblBTC.Columns("PlayingName").
`strTEST = objDataSet.Tables("tblBTC").Rows.Item("PlayingName").ToString()
` Iterate through the rows.
`Dim tblBTCDataRow As DataRow
`For Each tblBTCDataRow In tblBTC.Rows
`Console.WriteLine(tblBTCDataRow(0))
`Next
`Dim column As DataColumn = dt.Columns("Description")
`Dim tblBTCDataRow As DataRow = tblBTC.Rows(0)
Yahoo! Groups Links
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







