C# - Using Multiple Sql Queries On Single Button Click

Nov 16, 2010

protected void Button2_Click(object sender, EventArgs e)
{
String a = DropDownList1.SelectedItem.Value;
String b = DropDownList3.SelectedItem.Value.PadLeft(3, '0');
String c = TextBox2.Text.PadLeft(5,'0').ToString();
String d = TextBox3.Text.ToString();
String digit = a+ b + c + d;
try
{
myConn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=testcase;User=root;Password=root;Option=3;");
myConn.Open();
//**
string sql = "select * from testcase.main where reg_no =?";
//**
OdbcCommand cmd = new OdbcCommand(sql, myConn);
//**
cmd.Parameters.AddWithValue("?", digit);
MyReader = cmd.ExecuteReader();
//**
while (MyReader.Read())
{
String f = MyReader["pet_name"].ToString();
String g = MyReader["res_name"].ToString();
Label9.Visible = true;
Label9.Text = f;
Label10.Visible = true;
Label10.Text = "VS";
//Label11.Visible = true;
Label11.Text = g;
}
MyReader.Close();
}
catch (Exception e1)
{
Response.Write(e1.ToString());
}
finally
{
if (MyReader != null && !MyReader.IsClosed)
{
MyReader.Close();
}
if (myConn != null && myConn.State == ConnectionState.Open)
{
myConn.Close();
}
}

I want to add another sql query which is using two tables to fetch the data and than i want to display it in a dropdownlist after fetching data from database. How should i proceed?? Should i create a totally new connection? I tried many different ways like, creating new connection and new reader and entire try and catch block i coded again but on running the website i t was taking very long to load the contents. What i did i modified only this portion(below code) and used the entire try catch again but it dint work.

while (MyReader1.Read())
{
String f = MyReader1["ret"].ToString();
DropDownList1.Items.Add(f);
}

View 2 Replies


Similar Messages:

SQL Server :: Run Multiple Queries On Single Button Click

Jan 29, 2011

how to run multiple queries on a single button click. Actually I want whatever a user write in text box and click the button the text would get inserted in table category and also a table name project should get updated. I am using Sql server 2005 and c#

View 2 Replies

Web Forms :: How To Write Multiple Queries On A Single Button Click

Jan 27, 2011

Is it possible to write multiple queries on a single button click? if yes then how?

View 5 Replies

Web Forms :: Upload Multiple Files On Single Button Click

Jul 5, 2012

How to upload multiple images on single button click....

View 1 Replies

Web Forms :: Upload Multiple Files On Single Button Click?

Apr 10, 2013

I have reffered the Select and Upload Multiple Files Gmail Style using JQuery and ASP.Net to upload multiple files but i want to upload files in button click. how can i call the code in button click because above mentioned article uploads the file using upload .ashx?

View 1 Replies

Web Forms :: Clearing Multiple TextBox On Single Click Of Button

Sep 24, 2012

I have a web form with about  43 textboxes....currently if the use clicks cancel...all the textboxes are assigned an empty string. That works but what i really want i a better way to do this instead of having each textbox listed.

View 1 Replies

Data Controls :: Print Multiple GridViews On Single Button Click

Dec 14, 2012

on my webpage  having 5 gridview n when m click on PrintAll ... it combine all record in one gridview .....so wt can i do to get the Gridview as it is on after print .......n m rendering Div nt gridview . attaching code also.

gvincrement.AllowPaging = false;
gvincrement.ShowFooter = false;
// tblpan_cond.Visible = true;
gvincrement.DataSource = Session["key"];
gvincrement.DataBind();

[CODE]...

View 1 Replies

Databases :: Insert / Update Data To Multiple Tables On A Single Button Click

Sep 23, 2010

I need to insert/update data to 3 or more tables on a single button click.What is best method for achieving this?I am using mysql as my DB.

View 2 Replies

Data Controls :: Update Multiple GridView Rows On Single Button Click?

Jun 16, 2015

how can we update all rows without click on update link button,

or can we update all rows of gridview on click single "update" button instead of mutiple for everey row

View 1 Replies

Web Forms :: Save One Master And Multiple Detail Records On Single Button Click

Feb 18, 2013

i am working on project  where i have one master table "PURCHASE_ORDER" with fields

order_no  as primary key
vendor_id
order_date

and i have a detail table called "PURCHASE_ORDER_DETIALS" with fields 

sno,order_no,item,qty,rate.

i am supposed to create a master detail form 

where i am supposed to accept an order from an vendor with multiple items.

i.e the form shoud accept one master record and multiple detail records and then either save all  of them or discard all of them(both master and multiple detail records).

View 1 Replies

Web Forms :: Single DropDownList Running Multiple Queries?

Jun 16, 2010

I have a drop down with several option. I would like that if a certain item is select then a certain query will run. I read a post that
azamsharp on 12/23/03 .In that post he suggested to do:

string myProcedure = DropDownList.SelectedItem.value.ToString();

SqlCommand myCommand = new SqlCommand("myProcedure",myConnection);

while reading through the post it seems that this wasn't a great idea.

View 15 Replies

How To Validate Two Textboxes At Single Button Click Using Vb.net

Nov 22, 2010

How to validate two textboxes at single button click using vb.net ?

it shows an error :

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1 = "06:00:01 PM" & TextBox2.Text = "02:00:01 PM" Then
MsgBox "Submit"
End If
End Sub

Whatz wrong with my this code ? I wanna validate two checkbox using if statement ... on Button click

View 3 Replies

Web Forms :: Button Single Click Not Working

Jul 10, 2010

I had write the code for inserting data in a button click event..But, in order to insert , I should double click the button.

View 18 Replies

Multiple Button In A Single View

Sep 29, 2010

I have a web project which includes two button in a view.when i click a button some textboxes along with that second button have to be visible.After entering data in textboxes,when i am trying to click the second button, its not working.What should i do to make it work?

View 1 Replies

Vb.net - How To Print The Whole Webpage On Single Button Click Event

Feb 8, 2011

how to print the whole asp.net webpage on single button click event iusing VB ?

View 2 Replies

Web Forms :: Edit Update Multiple Gridview Row And Cell Values On A Single Click

May 25, 2012

Currently I have a grid view with few rows of data & edit and update for each row but I want it to be done on a single click with w external edit & save button how can the functionality be performed.

View 1 Replies

Web Forms :: How To Set Multiple Button In Single Image

Aug 23, 2010

I need to make multiple button in a single image in asp.net.and need coding also for vb.net.

View 4 Replies

Web Forms :: Multiple OnClientClick For Single Button

Sep 23, 2012

I have one button and want use Two script for it but i dont know how i can do it

<asp:Button ID="Button1" runat="server" Text="go" onclick="Button2_Click" OnClientClick = "SetTarget();"/>

and these are my script

<script type = "text/javascript">
function isNumeric(keyCode) {
var r = ((keyCode >= 48 && keyCode <= 57) || keyCode == 8 ||
(keyCode >= 96 && keyCode <= 105))
if (!r) {

[CODE]

View 1 Replies

Web Forms :: Link Button Cannot Open Popup On Single Click

Jan 4, 2011

i have to open the popup on from the gridview's linkbutton, bnut it open on the double click, not on the single click.

LinkButton btn = sender as LinkButton;

View 4 Replies

Two Validation Groups In A Single Button Without Client Click Event

Feb 24, 2010

In a multigrid i have validating two controls like date and amount.it is validating correctly when i press the tabevent.when i press the save button it is not validating.iam using two validations gruops and two validation summary.Then in save button i have also tried onclientclick() function with javascript it s working fine but if i give the correct value in date and amount records not saving how to over come this.

Date: ' runat="server" CausesValidation="true"
ValidationGroup="group" Width="80px" AutoPostBack="true" OnTextChanged="txtDate_TextChanged">
Amount" ' CausesValidation="true"
ValidationGroup="req" runat="server" AutoPostBack="true">
validations summary: button save: OnClick="ButtonSave_Click" TabIndex="6" />

how to validate this in the button save also two popup box should be shown

View 1 Replies

Javascript - How To Check All Checkboxes On Single Button Click Event

Apr 3, 2011

How to check all asp.net checkboxes on single asp.net button click event

if i have 45 checkboxes inside panel1 i want on button click event all the checkboxes will be checked and on another button click event all checkboxes will be unchecked...

how to do it using jquery, javascript or vb.net ?

View 3 Replies

Forms Data Controls :: After A Single Click All The Button Become Disable?

May 20, 2010

i have used a button in gridview.i want after a single click all the button become disable..

View 9 Replies

JavaScript - Multiple Create Requests Means Multiple Button Click Events For The Same Time?

Oct 19, 2010

I have a form which inserts data in DB on Submit button click but the problem is when client click the button multiple times its sends multiple create requests means multiple button click events for the same time of same data, which must not be.

I tried to disable the button when client click the Submit button first time but after this it does not call server click event handler or not fire the server click event once it got disabled.

How to handle this multiple click problem..

I used the following code to disable the button

[code]....

View 3 Replies

Web Forms :: Multiple Button Validation In Single Form

Apr 29, 2014

I am using two button click events and some required field validators . If I click the first button  the fields in  the other button also validates

I actually want to validate based on the button click if a first button is clicked  only the fileds which are under button1 should validate not the fields which are in button2.

I tried requiredfieldvalidator.enabled = false

it did not work.

View 1 Replies

Insert Record Into Database On Single Button Click From Date To Todate?

Mar 12, 2011

I have three textbox ... textbox1 and textbox2 and textbox3 I want when I choose from date in textbox1 say 1-May-2011 and to date in textbox2 say 30-May-2011 and in textbox I type 1,2,3,4,5 I want on button click ... event the values will be entererd in database from 1-May-2011 to 30-May2011 as : mentioned below :

DATABASE STRUCTURE
ID Date Items
1 1-May-2011 1,2,3,4,5
2 2-May-2011 1,2,3,4,5
3 3-May-2011 1,2,3,4,5

so on till 30_may-2011 Record will be inserted in database according to from date and to date choosen in textbox1 and textbox2 respectively.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved