ADO.NET :: How To Display Auto - Incrementing Value From Database In The Same Page Where Inserting Value
Feb 8, 2011
in my aspx page user is creating a request and when the request is created a request_id is generated automatically in databse..i want to retreive tht particular request_id and display it on the same web page.
here is my code-
protected void Button1_Click(object sender, EventArgs e)
{
String selection = DropDownList1.Text.ToString();
String status = "inactive";
try
{
ConnectionStringSettings set = ConfigurationManager.ConnectionStrings["WATERMARKING"];
String cns = set.ConnectionString;
SqlConnection cnn = new SqlConnection(cns);
cnn.Open();
String query = "Insert into REQUESTS (USERNAME,REQUEST_TYPE,STATUS) values ('" + uName + "','" + selection + "','" + status + "')";
SqlCommand cmd = new SqlCommand(query, cnn);
cmd.ExecuteNonQuery();
//Response.Write("Request created Successfully ");
//MessageBox.Show("request created successfully");
Label4.Visible.Equals(true);
Label4.Text="request created successfully";
Label5.Text = "Your Request ID is";
Label6.Text = "ID required to Check the Request Status";
}
catch (Exception err)
{
//Response.Write("error generated while raising request"+err);
Label4.Visible.Equals(true);
Label4.Text = "request creation error"+err;
}
}
here wen a value is getting inserted in REQUESTS table a column named REQUEST_ID gets populated and i want to display that value on the web page
View 7 Replies
Similar Messages:
Dec 6, 2010
i'm working on my first project on asp.net using c#.
I'm adding a couble of fields to database but i need the primary key of the master table to add it to sub table.
The database contains 2 tables :
Question Table :questionID(primary key and identity) , questionInText
Answer table : answerID , answer1,answer2 , questionID
code used to insert to db :
[code]....
View 1 Replies
Apr 27, 2010
I have an ID column (int) in my table which also needs to be a unique key.
last time I worked with a database (BD2), I set this as an autoIncrement feild and it would automaticaly 'deal with it' (ie, maintain the last used value somewhere and automaticaly used that value (after incrementing it) for any new row on the table).
How do I handle this in ASP.NET. Especially, as I try to add a new line based on form content when the user presses on a button (C#).
View 7 Replies
Apr 24, 2010
i am trying to display a pop up message box on inserting the data into the database. The code i am using is as follows..
[Code]....
The problem is even on inserting the data and the data getting inserted into the database, the pop up mwindow does not get displayed. On debugging, it shows the value of i as 0.
View 12 Replies
Mar 19, 2013
i m having 4 radio buttons on default2.aspx page on the same page i m using a database it's columns are uname and status whenever the user clicks on the radiobutton the status of that name should increment by 1(counter variable).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
[code]....
View 1 Replies
Nov 22, 2015
Incrementing and decrementing a count table by button click, when a user clicks a button the count table will increment by 1 and when the same user clicks the button the second time it will decrement by 1...
View 1 Replies
Mar 23, 2011
I got a table PartsMedia where I can insert all the images related to a product. The table has the columns :
PartsMediaID , auto-increment
PartsNo
MediaLink
MediaDescription
CatalogCode
SortCode
I want to insert a complete row with automatic increment and the PartsNo should be the same as the PartsNo from the PartsMaster table.
The medialink should be the PartsNo + '-2.jpg'
The mediadescription is for example 'image2'
The CatalogCode should be 'catalog'
and the sorting code should be '0'
From The partsMaster table I Just need the PartNo So I can add this to the PartMedia Table. The PartNo is the foreign key in the PartMedia table.
The following I got so far but no luck
insert into dbo.PartsMedia (PartNo,MediaLink,MediaDescription,CatalogCode, SortCode)
values (dbo.PartsMaster.PartNo, PartsMaster.PartNo+'-2.jpg','image2', 'catalog','0')
View 3 Replies
Dec 6, 2010
I'm adding a couble of fields to database but i need the primary key of the master table to add it to sub table.
The database contains 2 tables :
Question Table :questionID(primary key and identity) , questionInText
Answer table : answerID , answer1,answer2 , questionID
code used to insert to db :
[Code]....
questionID is auto increment.
The question is : How i get questionID after adding to database without using sql statment ?
View 1 Replies
Sep 29, 2010
there are two tables in database. one is 'books' with 4 columns pkid,title,price,writer(int) and other is 'persons' with columns pkid, name,value(int). one asp.net page is there with text boxes named title,price,writer and a submit button. i want that on filling that writer txtbox with some name which is available in 'persons' table and clicking that submit button it will store integer 'value' in 'books' writer column.
View 2 Replies
Jul 27, 2010
I have searched endlessly for an answer but found nothing useful! I'm writing a simple blog application using Web Matrix and its going pretty well, but I have run in to a problem. I am storing the content of each blog post in a ntext field in a table with the intention of entering HTML in to the database and then have my application pull it out and insert it in to a few different view pages. The problem is that all of the '<' and '>' characters are getting converted in to '<' and '>' when my application pulls the HTML from the database and displays it. I understand that this is for security (preventing code injection?), but only trusted users will ever be able to write posts using my application. Here is a screen shot of what gets displayed by my application:
Is there a way to disable this behaviour or work around it somehow?
View 3 Replies
Sep 1, 2010
I'm trying to insert few values to a table, when i press the submit button the aspx page goes blank and i don't get any error message. I'm not able to find where the error is.
The code:
Protected Sub AddMInfo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddMInfo.Click
View 5 Replies
Oct 28, 2012
I've a function named fillgrid() which fills the grid with data.This function works correctly on pageload,but after inserting into database i've called this function again, which is not getting executed.This issue happens only in real time server not in my local system,I'm not getting any error and i cannot recognize why fillgrid() function is not getting called??I've used update panel.This is the code for insert function which inserts over 500records.
DataTable dtMob = new DataTable();
dtMob = dtMobilizn.Copy();
DataSet dsMobilizn=new DataSet("dsMobilization");
[code]....
View 1 Replies
Mar 24, 2011
how to use 4 dynamically created timers on a single page for incrementing 4 different variables(int).
View 3 Replies
Sep 27, 2013
how can i make next or previous button in asp.net? for example, in collection will display all product that i sell...and i want the URL appear like this "/collections/other-fashion?page=1", when user click next, the URL change to "/collections/other-fashion?page=2"..is it i have to make many form? i just want to use 1 form...im using vb languange
View 1 Replies
Nov 20, 2013
there is 2 pages the first page include gridview its fill from xml file and there is button (Called add new student) when i click on this button its arrive me to second page and the second page inckude 5 Text box if to add new student.
** the problem with the ID of new student its can be show on the head page like this (http://localhost:57175/gridvieww/Default2.aspx?ID=8) i want head the ID number i am using query string now i want code to find the last node in xml and then increment +1.this is my code
XML code
<Students>
<Student>
<ID>1</ID>
<Name>hammad</Name>
<Email>hammad@xml</Email>
[code]....
View 1 Replies
Oct 6, 2010
I m trying to save files like pdf, word, excel etc... into sql express, but m getting this error in my web page:An attempt to attach an auto-named database for file C:Usersmalek.safaDocuments est vbSavingFileInDBSavingFileInDBApp_Dataaspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
m not getting errors inside my code, just this one appearing on the web page.
View 2 Replies
Apr 2, 2010
I've got a piece of code that is driving me crazy. No matter what I try, I can't get the javascript var to increment. BTW, I am using the jquery library.
<script type="text/javascript">
function formValidate() {
var counter = 0;
$.get("/Validation/ValidateNameFields", { inputString: $('#FirstName').val(), controlName: 'FirstName', messagePrefix: 'First Name' }, function(data) { if (data != "") { eval(data);counter++; } });
alert(counter) }
</script>
The eval(data); works just like its suppose to (it sets text to a label). The counter is always zero.
View 5 Replies
Mar 29, 2011
i am creating a page that will display multiple images from the database. i can do it if i will only display one image, by using a page to be rendered as image. something like this...
using (SqlDataReader reader = comm.ExecuteReader())
{
Byte[] images = new Byte[]();
while (reader.Read())
{
Response.BinaryWrite(images);
}
}
and in the aspx file i have: <asp:Image ID="imgPhoto" runat="server" ImageUrl="~/ShowImages/LoadImages.aspx" Height="100px" Width="100px" BorderWidth="1px" /> what i want to achieve is to display multiple images from the database without making a page to be rendered as image...
View 2 Replies
Jan 22, 2011
have sql server, with databaste that i created with one test table.i need to disply the database i try with Gridview but it's dosn't worked, how can i display my database?b.wi know ADO c# , i know how to work with databases on winform. but i never try to do this with asp page,if enyone can send me some good guide to create the connection, and use, insert,update ect..
View 4 Replies
May 16, 2012
I have one div in my page i want show my store information in that div from DB
Name:Itally mall
Address:Italy
Tel:123456879
Description:test test test
It is just one time per page how i can do it?I know that i can use gridview,datalist but here i just need read my data just 1 time from DB i dont want repeat it so what can i do?
View 1 Replies
Jun 20, 2012
How to display the data in title tag from database in asp.net
eg
<html xmlns="[URL]">
<title>Here i want to display the data using server control </title>
</head>
<body>
<form id="form1" runat="server">
.....
</form>
</body>
</html>
View 1 Replies
May 28, 2010
I am inserting a picture into a database, using the following code.
strFileType = Path.GetExtension(filImage.PostedFile.FileName).ToLower();
switch (strFileType)
{
case ".gif":
strMimeType = "image/gif";
break;
case ".jpg":
case ".jpeg":
case ".jpe":
strMimeType = "image/jpeg";
break;
case ".png":
strMimeType = "image/png";
break;
}
//Store the content length
int iDocLength = filImage.PostedFile.ContentLength;
byte[] bDocBuffer = new byte[iDocLength];
//Get stream object
Stream streamImage;
streamImage = filImage.PostedFile.InputStream;
streamImage.Read(bDocBuffer, 0, iDocLength);
cmPerson.CommandText = "INSERT INTO photos VALUES(@referenceid, @image, @imgtype)";
cmPatient.Parameters.AddWithValue("@referenceid", iPersonID.ToString("000000"));
cmPerson.Parameters.AddWithValue("@image", bDocBuffer);
cmPerson.Parameters.AddWithValue("@imgtype", strMimeType);
cmPerson.ExecuteNonQuery();
If in case that the user, did not browser for a picture, then, I have to use the nopho.jpg that is stored in the images/folder of my web app. How am I be able to do this?
View 1 Replies
Oct 10, 2010
[Code]....
[Code]....
[Code]....
[Code]....
[Code]....
View 2 Replies
Feb 9, 2011
my sql db configured with getdate()
i need insert time manually when i ll need.
created texbox and when i inputing date and time manually in right format its ok.
but i need set default date and value for textbox current date and time.
at the same time when i will need to input time manually i can be.
here is my vb code row for inserting time to sql db
cust.HaberTarih = saat.Text
how can i set text box default value to current date and time. and can change time part when i will need.
View 1 Replies
Feb 8, 2011
I have two ddl'a which i insert into a database inform of a grid. Now i will like to make sure the two data i am inserting is not already on the databse and if it exist i want a message to show. I dont have anything right now. I just need ideas on how to go about it.
View 9 Replies