in my project..
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Check Username availability Using Ajax</title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtvoucher" runat="server"></asp:TextBox>
<asp:Button ID="btnsubmitvoucher" runat="server"
onclick="btnsubmitvoucher_Click" Text="Submit" />
<br />
<br />
<asp:Label ID="lblmsg" runat="server"></asp:Label>
<asp:TextBox ID="txtCpoints" runat="server"></asp:TextBox>
<asp:TextBox ID="txtusername" runat="server"></asp:TextBox>
</form>
</body>
</html>
This my default page design.
and code behind
using System;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnsubmitvoucher_Click(object sender, EventArgs e)
{
int strvoucher = Convert.ToInt32(txtvoucher.Text);
con.Open();
OleDbDataAdapter da = new OleDbDataAdapter("select * from coupen where voucher=" + strvoucher, con);
DataTable dt = new DataTable();
da.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
int V = Convert.ToInt32(dt.Rows[0][0]);
if (strvoucher == V)
{
OleDbCommand cmdselect = new OleDbCommand("select* from coupen where voucher=" + strvoucher, con);
OleDbDataReader rs;
con.Open();
rs = cmdselect.ExecuteReader();
if (rs.Read())
{
txtCpoints.Text = rs.GetValue(2).ToString();
int tt = Convert.ToInt32(txtCpoints.Text);
OleDbCommand cmd = new OleDbCommand("UPDATE LOGIN SET CPoints " + tt + " WHERE U_name = " + txtusername.Text, con);
}
con.Close();
lblmsg.Text = "Congrats your voucher is accepted check your points !!!";
}
else
{
lblmsg.Text = "Invalid voucher ..!!";
}
}
else
{
lblmsg.Text = "Invalid Login..!!";
}
}
}
and the have used access database.
I have two tables:
1. coupen
2. LOGIN
In
coupen table fields are:
voucher-Number,<br />
RS-Number,<br />
CPoints-Number,<br />
Datec-Date/Time
and the data in this table data
222,2,2,3/15/2013
111,4,4,3/18/2013
In
LOGIN Table field are
U_id-AutoNumber,<br />
U_name-Text,<br />
U_Email-Memo,<br />
U_Mobile-Memo,<br />
U_password-Memo,<br />
CPoints-Number...
in this table data:
1,aaa,a@a.com,123456,123
3,bbb,ashish@gmail.com,987654,-...
when run the page plz Enter the voucher no in the text box..and click submit...after clicking button point will be displayed in 2nd text box , Enter the user name in 3rd text box...and again click submit button...
when clicked the button the "CPoints" related data will be deleted from coupen and that "CPoints" will be update in the LOGIN table related to the U_name..
problem is that when i clicked the submit button 2nd time the login table is not updated..
if u getting my point.
plz help me...