Flex dot net example, Flex .net, Flex asp.net, Flex dotnet, Flex with asp.net,  HTTPServices example
The asp.net code for the Previous Flex example. default.aspx I am just posting the body part of default.aspx
The User table has three fields UserId,UserName,email
    <form id="form1" runat="server">
    <div>
          <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
            id="Flex3" width="100%" height="100%"
            codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
            <param name="movie" value="FlexDotNet.swf">
            <param name="quality" value="high">
            <param name="bgcolor" value="#869ca7">
            <param name="allowScriptAccess" value="sameDomain">
            <embed src="FlexDotNet.swf" quality="high" bgcolor="#869ca7"
                width="100%" height="100%" name="Flex3" align="middle"
                play="true"
                loop="false"
                quality="high"
                allowScriptAccess="sameDomain"
                type="application/x-shockwave-flash"
                pluginspage="http://www.adobe.com/go/getflashplayer"></embed>
            
    </object>
    </div>
    </form>
------------------ Code behind code default.aspx.cs -----
using System;
using System.Configuration;
using System.Collections;
using System.Data;
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;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        displaydata();
    }
    public void displaydata()
        {
            SqlConnection con = new SqlConnection(@"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=yourUserId;Password=YourPassword;Initial Catalog=YourDatabaseName;Data Source=yourServerName"    );
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from Users",con);
            cmd.con.open();
            da = new SqlDataAdapter(cmd);
            ds = new DataSet();
            da.Fill(ds, "Users");
            mxmlStr = "<users>";
            foreach (DataRow dr in myDataSet.Tables["EmployeeData"].Rows)
           
            {
           
                    mxmlStr = mxmlStr + "<user><userid>" + dr[0].ToString() + "</userid><username>" + dr[1].ToString() + "</username><emailaddress>" + accessSqlArray(2,mxmLoop) + "</emailaddress></user>";       
               
            }       
            mxmlStr = mxmlStr & "</users>";
            response.write(mxmlStr);
           
        }
}
------------------------ Code Behind DeleteRequest.aspx.cs---------------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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.Data.SqlClient;
public partial class deleteRequest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        displaydata();
    }
    public void displaydata()
    {
        string mxmlStr;
        string strUserId;
     
        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=yourServerName;Initial Catalog=yourDataBase;User ID=yourUserId;Password=yourPassword;";
        con.Open();
        strUserId = Request.Form["user_id"];
        if (Request.Form["user_id"] != "")
        {
            SqlCommand cmd = new SqlCommand("Delete from Users WHERE UserId =" + Request.Form["user_id"] , con);
            cmd.ExecuteNonQuery();
        }
        Server.Transfer("default.aspx");
    }
}
------- Code Behind for addRequest.aspx  -----------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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.Data.SqlClient;
public partial class addRequest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        displaydata();
    }
    public void displaydata()
    {
        string mxmlStr;
        string strUserName, strEmail, strMaxId;
        
        Int32 intMaxId;
        //SqlConnection con = new SqlConnection("User ID=yourUserId;Password=yourPassword;Initial Catalog=yourDataBase;Data Source=yourServerName");
        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=ARULM;Initial Catalog=guest1;User ID=sa;Password=sa;";
        con.Open();
        strUserName = Request.Form["add_username"];
        strEmail = Request.Form["add_email"];
        if (Request.Form["add_username"] != "")
        {
            SqlCommand cmd = new SqlCommand("select max(UserId) as strMaxId FROM Users", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "Users");
            mxmlStr = "
            //DataRow dr = new DataRow();
            //ds.Tables["
            strMaxId = ds.Tables["Users"].Rows[0][0].ToString();
            intMaxId = Convert.ToInt32(strMaxId) + 1;
            SqlCommand cmd2 = new SqlCommand("insert into Users (UserId,UserName,email) values (" + intMaxId + ",'" + strUserName + "','" + strEmail + "')", con);
            cmd2.ExecuteNonQuery();
        }
        Server.Transfer("default.aspx");
    }
}
---------- SaveRequest.aspx.cs-------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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.Data.SqlClient;
public partial class saveRequest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        displaydata();
    }
    public void displaydata()
    {
        string mxmlStr;
        string strUserName, strEmail, strMaxId;
        string strUserId;
        Int32 intMaxId;       
        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=yourServerName;Initial Catalog=yourDatabaseName;User ID=yourUserId;Password=yourPassword;";
        con.Open();
        strUserName = Request.Form["add_username"];
        strEmail = Request.Form["add_email"];
        strUserId = Request.Form["adduser_id"];
        if (Request.Form["adduser_id"] != "")
        {            
            intMaxId = Convert.ToInt32(strUserId);
            SqlCommand cmd2 = new SqlCommand("update users set UserName ='" + strUserName + "',email ='" + strEmail + "' where UserId = " + intMaxId, con);
            cmd2.ExecuteNonQuery();
        }
        Server.Transfer("default.aspx");
    }
}
----- addRequest.aspx.cs  -----
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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.Data.SqlClient;
public partial class addRequest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        displaydata();
    }
    public void displaydata()
    {
        string mxmlStr;
        string strUserName, strEmail, strMaxId;
        
        Int32 intMaxId;
        
        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=yourServerName;Initial Catalog=yourDatabaseName;User ID=yourUserId;Password=yourPassword;";
        con.Open();
        strUserName = Request.Form["add_username"];
        strEmail = Request.Form["add_email"];
        if (Request.Form["add_username"] != "")
        {
            SqlCommand cmd = new SqlCommand("select max(UserId) as strMaxId FROM Users", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "Users");
            mxmlStr = "
            strMaxId = ds.Tables["Users"].Rows[0][0].ToString();
            intMaxId = Convert.ToInt32(strMaxId) + 1;
            SqlCommand cmd2 = new SqlCommand("insert into Users (UserId,UserName,email) values (" + intMaxId + ",'" + strUserName + "','" + strEmail + "')", con);
            cmd2.ExecuteNonQuery();
        }
        Server.Transfer("default.aspx");
    }
}
Monday, 24 March 2008
Posted by
Unknown
at
12:18:00 pm
 
 
Labels: Flex .net, Flex asp.net, Flex dotnet, Flex with asp.net, HTTPServices example
Subscribe to:
Post Comments (Atom)
 


 del.icio.us
 del.icio.us Flickr Photos
 Flickr Photos
No comments:
Post a Comment