How To Get From Loop Session On Data Reader
Nov 26, 2010I am trying to send session on Loop and trying get .
[code]....
In above code, I just only get same SessionId on every news headings, how do I get next row session id?
I am trying to send session on Loop and trying get .
[code]....
In above code, I just only get same SessionId on every news headings, how do I get next row session id?
how I can loop through the results in VB, I only ever seem to get the last row, I would like to list all rows.
My code is below
[Code]....
I have following code that I can only add one image per row although I can add Listbox items as I wanted.
If "imgtag" 1~5 is checked, I get these in the listbox.
ie. ImageID = "cat"
listbox1. item gets - cat1, cat2, cat3, cat4, cat5
however I can only create the last image instead of 5 images.
- imageID - cat5
I assign each image unique ID.
If reader2.HasRows Then
While reader2.Read
Dim img1 = Convert.ToString(reader2("imgtag1"))
Dim img2 = Convert.ToString(reader2("imgtag2"))
Dim img3 = Convert.ToString(reader2("imgtag3"))
Dim img4 = Convert.ToString(reader2("imgtag4"))
Dim img5 = Convert.ToString(reader2("imgtag5"))
Dim blogimg = Convert.ToString(reader2("ImageID"))
Dim a As New HyperLink
a.Attributes.Add("onclick", "return hs.expand(this)")
a.Attributes.Add("href", "../../blog/images/" + blogimg)
Dim img As Image = New Image
img.ImageUrl = "~/blog/images/" + blogimg
img.Width = 200
If img1 = "1" Then
Dim blogimg1 As HtmlTableCell = CType(FindControl("blogimg1"), HtmlTableCell)
img.ID = blogimg + "1"
a.Controls.Add(img)
blogimg1.Controls.Add(a)
ListBox1.Items.Add(blogimg + "1")
End If
If img2 = "1" Then
Dim blogimg2 As HtmlTableCell = CType(FindControl("blogimg2"), HtmlTableCell)
img.ID = blogimg + "2"
a.Controls.Add(img)
blogimg2.Controls.Add(a)
ListBox1.Items.Add(blogimg + "2")
End If
If img3 = "1" Then
Dim blogimg3 As HtmlTableCell = CType(FindControl("blogimg3"), HtmlTableCell)
img.ID = blogimg + "3"
a.Controls.Add(img)
blogimg3.Controls.Add(a)
ListBox1.Items.Add(blogimg + "3")
End If
If img4 = "1" Then
Dim blogimg4 As HtmlTableCell = CType(FindControl("blogimg4"), HtmlTableCell)
img.ID = blogimg + "4"
a.Controls.Add(img)
blogimg4.Controls.Add(a)
ListBox1.Items.Add(blogimg + "4")
End If
If img5 = "1" Then
Dim blogimg5 As HtmlTableCell = CType(FindControl("blogimg5"), HtmlTableCell)
img.ID = blogimg + "5"
a.Controls.Add(img)
blogimg5.Controls.Add(a)
ListBox1.Items.Add(blogimg + "5")
End If
End While
I'm currently trying to build a html table from the results of a sql data reader. As my table has multiple records, I want the code to loop through the reader and output the details on individual lines of the page. In ASP I have done this in the past using something like
[Code]....
but as I am using data readers I'm not sure what the equivalent is.
I have some code in my vb.net code behind that queries a database, and if there is data, outputs it from the codebehind to a datalist on my asp.net page. In addition to sending the data to the datalist on the page, I need to take the value from "mbillaty" that is returned from the sql query, and have that value be the selected value for a drop down box also on the page. I can get either the datalist to fill, or the selected value for the dropdown box to be selected depending upon which bit of code I place before the other (ARGH), but I can't get them to both work together on the page. What am I doing wrong?
[Code]....
I would like to dropdown box to show only starting from second row of the table. How to use data reader to do it?
View 9 Repliesis it possible to find row count of a table using data reader?
View 3 RepliesI have a string coming from a stored procedure looks like '001234567'.
sqlCommand = new SqlCommand("csp_Bbp_OBN_GetBasePageList", BBConnection);
sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
sqlCommand.Connection.Open();
// Run the SQL statement, and then get the returned rows to the DataReader.
accReader = sqlCommand.ExecuteReader();............
In my case, from the stored procedure I am returning the varchar, after executing and reading it I am getting the value to basePage.GrouNum which is a string. So, I don't see where it is trimming the leading zeros.
Example: GroupNumber in the table is : "001234567"
BasePage.GroupNum after reading from DataReader : "1234567"
But, I do not want the leading zeros being trimmed.
I have a web page where I want to return number of returned rows by datareader as I need to get Count of rows. My code is as follow :
SqlCommand cm = new SqlCommand(); SqlDataReader dr;sqlconnection cn; public int Returndatareader( int x)
{
int s;
string sqlstr = "SELECT COUNT(*) FROM P_Events as Counter";
cm.CommandText = sqlstr;
cm.Connection = cn;
cn.Open();
dr = cm.ExecuteReader();
if (dr.Read())
{
int y = dr.RecordsAffected;
s = y;
//return y;
}
cn.Close();
return x;
}
but the rows affected count is -1 everytime i run my code.
Had a datareader question.
[Code].......
Return myDataReader I have a function which is retuning a datareader to various sections of my website which is then being bound to dropdown lists, gridviews, etc. Normally the last line in a function when is the data reader and connection getting closed? Is it best practive to return a data reader or a dataset/datatable (or something even better than these two)?
[Code]....
why I am not getting the desired result. I want to retrieve records in DataReader and still I am not getting any result.
Here is what I have tried:
txtCost.Text = string.Format("{o:c}", dr["Cost"]);
Here is the error I receive. How can I format the data that is coming from the data reader into currency format??? Also, is there a way to format it into currency without the dollar sign?
Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
[Code]....
but if table is empty i.e. there is no record for Store_no=storeno then it bill_id = (Convert.ToInt32(reader[0]) + 1); give a Null exception.
I want to set bill_id=1 if there is no previous record in table of that particular store number. then How to do this.
i.e. How to check that reader[0] is null
cmd1 = new SqlCommand(" Select Max(Bill_No) From Bill_Record Where Store_no='" + storeno + "'", hookUp);
While dr.Read()
View 2 Replieswhen i found datareader object containing data after execution of query
simply giving gridviewdata=dr;
does not work
I have a GV that is populated via a reader: Using reader As SqlDataReader = cmd.ExecuteReader() I have autogenerate edit button=T but it will not go into editmode. Must I create template to handle this?
View 4 RepliesI am Confused about the TextReader Class,that how it fetched data ?And from where it fetches data?
Is this the base class of all other Reader type classes?
I have this code:
SqlDataSource1.SelectCommand = "Select (AttributeName +'|'+ Value) DisplayTextField tbl_PaymentDetails FROM WHERE AttributeName =" Credit card number ';
[code]...
DropDownList3 click on some text.
Example:
dropdownlist3 ... Test1 (Read in the table)
dropdownlist3 ... Test2 (read from table)
dropdownlist3 ... Test3 (read from table)
[code]...
so i have a content page that load some content into repeater one of the repeater items is UserControl, when the page is load for the first time everything is perfect, but if i try to do postback and reload the repeater i get this error:
Code:
Exception Details: MySql.Data.MySqlClient.MySqlException: Invalid attempt to Read when reader is closed.
this error is raised in the repeater databind event.
So far i've populated my grid view with my roomID. however using data reader I don't seem to be able to get more than one column to auto generate even though i'm now looking for three values : SELECT tt_roomEquip.roomID, tt_room.roomCapacity, tt_equip.equipTitle is my select bit of the sql, though it's only putting roomID into my grid view.
View 1 RepliesI am getting following compilation error Invalid attempt to call FieldCount when reader is close
Why the binding order is giving an error.
[Code]....
I am using Page.Databind() because of the following in .aspx file
[Code]....
I have following Functions in .cs file
[Code]....
Im stuck with declaring a string which is in a loop within another loop.
Dim CompanyDetails As String = ""
Dim CompanyRow As DataRow
For Each CompanyRow In newdt.Rows
CompanyDetails += CompanyRow(1) & " " & CompanyRow(0) & "<br/>"...
How can I get this to see the GetInfo as declared..... since its in a loop within a loop?
I'm stuck in converting the rate in the datalist. My page contain one dropdownlist(currency converter), one datalist - inside contain the price of bags in labels. Now I uses the dropdownlist.selectedIndexchange
[code]....
Althought it did convert the rate, but it only convert the first row.
I have an ashx page that returns the following JSON data that I would like to be able to loop through and add to values to a bunch of li's in a ul.
My question is how do I loop through to retrieve the values.
The data that is returned from the ashx look slike this
{"ImageCollection":
{
"Images":
[
{
"ImageID":"62",
"CatID":"1",......
I get a single alert that says undefined. What am I doing wrong?
in my button4 click event, i want to insert checboxlist items to data table. first i want to delete all of the exisiting and then insert again.
my code is below but it is not working if you could explain anyone ?
in page load I have written code so that existing checkbox items are selected.
[code]...