ExecuteScalar: Carrying Value To Another Page?
Aug 30, 2010I need to carry the newly created value to another page using the ExecuteScalar method, I'm using the try catch finally but I'm a bit stuck with it,
[Code]....
I need to carry the newly created value to another page using the ExecuteScalar method, I'm using the try catch finally but I'm a bit stuck with it,
[Code]....
I'm using Radio button List for the first time.I have a radiobutton list on the page:
<asp:RadioButtonList ID="Pending" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="Populategrid" Height="16px"
RepeatDirection="Horizontal" Width="755px">
<asp:ListItem Value="250">Pending Over 250</asp:ListItem>
<asp:ListItem Value="300">Pending Over 300</asp:ListItem>
<asp:ListItem Value="350">Pending Over 350</asp:ListItem>
<asp:ListItem Value="400">Pending Over 400</asp:ListItem>
</asp:RadioButtonList>
Here's the gridview. I want to take the selection over in a querystring
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource7" EnableModelValidation="True" Width="331px"
CaptionAlign="Top" Height="126px" BackColor="White" BorderColor="#DCBE68"
BorderStyle="Solid" BorderWidth="1px" CellPadding="4"
[code]....
Look at the first hyperlink I've added the selected value which takes me to the next page.On the Pending DDS.aspx page what do I put in pageload?I want to take the selection over in a query string 0..I have a radio button list on the Pending DDS.aspx page so when you come in on the first page click 250 button (in radio button list) and then click the link to go to Pending DDS.aspx page I want that radio button to be selected when the user comes to that page.
ve a very strange problem in my asp.net shopping cart applicaition. Every new item order will be stored as a generic list in class file as below
Dim NewItem
As
New CartItem()
[code]...
We use an agent to monitor user activity on our site. It manages a user session together by matching the asp.net session ID.
If we were to launch a separate checkout site on a new domain, would we be able to force carry the current Session ID from the standard non SSL site to the new session on the checkout site - this way our agent would match the session together, as we require?
've got a website that's written in php and I'm attempting to re-create it in ASP.NET, so far I think I'm doing well with the help of this great community. How can I carry over pre-existing redirects in ASP.NET?
Is there some kind of file that I can store them all in, that gets read?
I have this SQL Select statement to select the basket id where the user id equals a specific ID.I want to store the result of the query in a variable, so I thought I could have done:
BasketPage.SelectCommand="SELECT BasketID FROM tblBasket WHERE (UserID = '9f96bd94-91b9-4328-8214-4eac179c3a26')"
var BasketID = BasketPage.ExecuteScalar().ToString();
But apparently I need to create a new instance of an SQL Command for it to work, how can I do this for the BasketPage Select Command?
I need to build an address list gridiview that has 3 search boxes - First Name, Surname, Address. How do i set it up so you can use one of 3 different where clauses? or possible 2 where clauses prior to the databind??
I dont want to search / filter a gridview that has already been databind, i want the search to go straight to the DB if possible.
I have the SqlCommand Problem. cmd is the sqlcommand and when run cmd.Executescalar(), what will it return??
As I have the problem below code that it always prompt invalid cast which may be in the assigning BAtchno.
What do you think?? How to Correct below code??
--------------------------------------------------------
sSQL = "select max(batchno) from QI_WMS.dbo.WMS_StockRelease_Shipment with(nolock) "
+ " where convert(varchar, SRDate, 111) = @DateReceive and
WarehouseID=@WarehouseID";
[code]...
I know for a fact that the SQL statement below returns NULL but my code statement "if (obj != null)" is not working.When I debug it I see a value of {} ... not sure what that is. Here is my code:
[Code]....
So, even if SQL returns NULL, it still validates obj as NOT NULL !
I posted a question about how to save the result of an SQL command to a variable and was told that the execute scalar method should be used, however I can't use it, I'm using the System.Data.SQLClient reference but still not finding it
View 3 RepliesI have a simple procedure which updates a table. The procedure works fine and I have tested it in Management Studio. However when I am calling that procedure from code, nothing is happening. cmd.ExecuteScalar returns null when it should return the ID.Has anyone faced anything similar? Any pointers as to how this can be resolved?
View 3 RepliesI am using following oracle query and using executescalar() to fetch data
sql = "select username from usermst where userid=2"
string getusername = command.executescalar();
But It is showing me error "System.NullReferenceException: Object reference not set to an instance of an object"
This error comes when there is no row exist in database for userid=2
Since both retruns the value. Then whats is the difference between ParameterDirection.ReturnValue and ExecuteScalar()
int i = Convert.ToInt32(cmd.ExecuteScalar())
objCmd.Parameters.Add("@ColumnnTest", SqlDbType.Decimal).Value = objPropertiesClassName.Columnnumeric;
objCmd.Parameters["@Columnnumeric"].Direction = ParameterDirection.ReturnValue;
objCmd.ExecuteNonQuery();
int i = (int)objCmd.Parameters["@Columnnumeric"].Value;
I use below code for my button event
int Result = _cmd.ExecuteNonQuery();
if (Result > 0)
{
Session["Login"] = true;
Response.Redirect("~/Managers.aspx?BehCode=" + Server.UrlEncode(TextBox1.Text));
}
But it didn't work it didn't go to managers.aspx page but when I replace code with below code it worked correctly it go to managers.aspx
int count = Convert.ToInt32(_cmd.ExecuteScalar());
if (count > 0)
{
Session["Login"] = true;
Response.Redirect("Managers.aspx?BehCode=" + Server.UrlEncode(Txtbeh.Text));
}
Why this happen whats exact different between two code?
ExecuteScalar requires an open and available Connection. The connection's current state is closed.
namespace ITS_Group{ public partial class Login : System.Web.UI.Page {
private DataTable GetData(SqlCommand cmd) {
DataTable dt = new DataTable();
String strConnString = System.Configuration.ConfigurationManager.ConnectionStrings[1].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
[CODE]..
I hope this is the right forum for this question.The statement , object obj = cmd.ExecuteScalar() is returning 2010-10-22 18:25:36However is not bringing the last 3 digits (miliseconds).This is actually calling the following SQL query: select max(timeStamp) from Table1 which returns 2010-10-22 18:25:36.713 on query analyzer. As you can see "713" is not being included ...How do I bring this value?
View 2 RepliesMy httppost action doesnt seem to have received my model. The code is below;
[Code]....
i put a breakpoint on the line; return RedirectToAction("Error", "Dashboard"); and i found that appQualif carried no values whatsoever from the form i submitted..
I have VS 2010 professional. I am trying to open "ASP.Net Configuration" through Project -> ASP.Net Configuration.
It pops up the Notification about the ASP.Net Development Server localhost but doesn't open ASP.Net Configuration in the default browser.I clicked on the Root Url (by double clicking on the 'development server' at the right bottom from Notification Manager).
It throws following error
"An error was encountered. Please return to the previous page and try again."
Clicking on "How do i use this tool".It opened page with error.
Tool Has Timed Out
in my project i kept two forms if i click the first form submit button it will transfer to second page if i click the second page submit button it will transfer to first page . SO WHAT I NEED IS
1. I WANT TO KNOW HOW MANY RECORDS THEY ARE ENTERING i.e IF THEY CLICK THE SECOND PAGE SUBMIT BUTTON THEY COMPLETED ONE FORM I WANT TO MAINTAIN A COUNTING .
I'M NOT GETTING ANY IDEA IF U EXPERTS HAD SOME IDEAS TELL ME WITH CODING.
if we keeping session means how?
PLATFORM:ASP.NET 3.5 CS:VB.NET DB:SQL2005
I'm using Visual Studio 2008, and my database is SQL Server 2000.
I want to add a connection to the Server Explorer in VS. The Data source is Microsoft SQL Server (SqlClient). After entering in all my information and I click Test Connection, it is successful.
But when I click OK, I get the error:
Unable to add data connection. ExecuteScalar requires an open and available connection. The connection's current state is closed.
My master page looks like:
<head runat="server">
<title>
<asp:ContentPlaceHolder ID="PageTitlePlaceHolder" runat="server" />
</title>
Content pages look like:
<asp:Content ID="TitleContent1"
ContentPlaceHolderID="PageTitlePlaceHolder" runat="Server">
My Page
</asp:Content>
This works by placing the content page specific title on the page ("My Page" in this example). Now I want to add a global prefix to the title in my master page for the site name. So I want:
<head runat="server">
<title>
Example.com:
<asp:ContentPlaceHolder ID="PageTitlePlaceHolder" runat="server" />
</title>
However, when I do this content pages are still rendered without "Example.com" in the tile, it's like it's ignored.
Why is this happening and how can I achieve this?
I want to share a common page load and page init events sequence between Master page and child page and User Control as described below:
Let us have the following components:-
1. TestMaster.master -> It is the master page
2. TestChild.aspx -> It is the Child page
3. TestUserContrl.ascx -> It is the UserControl present within the TestMaster.master page.
[code]...
I am using Master page and Content page combination.But how can i access <body> tag and it's event (onload, onunload) of Master page in .aspx page that is not a content page.
View 12 RepliesI have a master page homeMaster.aspx and many content pages. However the situation is I have few .html pages. Now when a user clicks on a link the html page should get loaded.inside the master page. The problem is these are .html and not content page with .aspx.
View 4 RepliesI've encountered a problem when I put a treeview in a page which is using master page. The treeview style doesn't apply.For example, I set the nodes with different colors in different levels. But the treeview nodes are still displayed in the default color(bule).
The treeview code is :
[Code]....
If I use these code in a page which doesn't use a master page. The nodes are shown in colors.