نمایش نتایج 1 تا 4 از 4

نام تاپیک: مسیر دیتابیس sql server

  1. #1

    مسیر دیتابیس sql server

    با سللم
    من یه سورس کد صفحه لاگین دانلود کردم!!!
    ببینید که برای تغییر مسیر دیتابیس باید کدوم رو عوض کنم!!!
    در ضمن سرور من لوکال است و دیتابیسم مستر است

    login.aspx


    <%@ Page language="C#‎" Codebehind="Login.aspx.cs" AutoEventWireup="false" Inherits="University.Login" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>Login</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#‎">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout" bgColor="#ffe4b5">
    <form id="Form1" method="post" runat="server">
    <asp:TextBox id="txtLogin" style="Z-INDEX: 101; LEFT: 192px; POSITION: absolute; TOP: 56px" runat="server"></asp:TextBox>
    <asp:Image id="ImageLoginFail" style="Z-INDEX: 110; LEFT: 32px; POSITION: absolute; TOP: 208px"
    runat="server" ImageUrl="Pictures/login.gif" Visible="False"></asp:Image>
    <asp:Label id="Label2" style="Z-INDEX: 104; LEFT: 112px; POSITION: absolute; TOP: 112px" runat="server">Password</asp:Label>
    <asp:TextBox id="txtPassword" style="Z-INDEX: 103; LEFT: 192px; POSITION: absolute; TOP: 104px"
    runat="server" TextMode="Password" Width="152px"></asp:TextBox>
    <asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 112px; POSITION: absolute; TOP: 56px" runat="server">Login</asp:Label>
    <asp:RequiredFieldValidator id="RequiredFieldValidator1" style="Z-INDEX: 105; LEFT: 392px; POSITION: absolute; TOP: 64px"
    runat="server" ErrorMessage="Please enter Login Name" ControlToValidate="txtLogin"></asp:RequiredFieldValidator>
    <asp:RequiredFieldValidator id="RequiredFieldValidator2" style="Z-INDEX: 106; LEFT: 392px; POSITION: absolute; TOP: 104px"
    runat="server" ErrorMessage="Please enter password" ControlToValidate="txtPassword"></asp:RequiredFieldValidator>
    <asp:Button id="btnLogin" style="Z-INDEX: 107; LEFT: 112px; POSITION: absolute; TOP: 168px"
    runat="server" Width="96px" Text="Sign On" Height="32px"></asp:Button>
    <asp:Label id="LabelError" style="Z-INDEX: 108; LEFT: 176px; POSITION: absolute; TOP: 272px"
    runat="server" Width="456px" Height="48px" Font-Bold="True" Font-Size="Medium" ForeColor="DarkOrange"
    Visible="False">Opps!! Wrong login/password.</asp:Label>
    <asp:Button id="btnNewUser" style="Z-INDEX: 109; LEFT: 248px; POSITION: absolute; TOP: 168px"
    runat="server" Width="90px" Height="32px" Text="New User"></asp:Button>
    </form>
    </body>
    </HTML>



    login.aspx.cs


    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Web.Security;
    using System.Data.SqlClient;

    #region Shail Srivastav , shailsrivastav@hotmail.com
    // Shail Srivastav
    // This code is wriiten by Shail Srivastav
    // shailsrivastav@hotmail.com
    // Please do not delete this part.
    #endregion

    namespace University
    {
    /// <summary>
    /// Summary description for Login.
    /// </summary>
    public class Login : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox txtLogin;
    protected System.Web.UI.WebControls.Label Label1;
    protected System.Web.UI.WebControls.TextBox txtPassword;
    protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
    protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
    protected System.Web.UI.WebControls.Button btnLogin;
    protected System.Web.UI.WebControls.Label LabelError;
    protected System.Web.UI.WebControls.Button btnNewUser;
    protected System.Data.SqlClient.SqlConnection sqlConnection1;
    protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapterLogin;
    protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
    protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
    protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
    protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
    protected University.DataSetLogin dataSetLogin;
    protected System.Web.UI.WebControls.Image ImageLoginFail;
    protected System.Web.UI.WebControls.Label Label2;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here
    }

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    this.sqlDataAdapterLogin = new System.Data.SqlClient.SqlDataAdapter();
    this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
    this.dataSetLogin = new University.DataSetLogin();
    ((System.ComponentModel.ISupportInitialize )(this.dataSetLogin)).BeginInit&#4 0;);
    this.txtPassword.TextChanged += new System.EventHandler(this.TextBox2_TextChanged& #41;;
    this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
    this.btnNewUser.Click += new System.EventHandler(this.btnNewUser_Click) ;
    //
    // sqlConnection1
    //
    this.sqlConnection1.ConnectionString = "workstation id=GUDDU;packet size=4096;user id=sa;data source=local;persist securi" +
    "ty info=False;initial catalog=master";
    //
    // sqlDataAdapterLogin
    //
    this.sqlDataAdapterLogin.DeleteCommand = this.sqlDeleteCommand1;
    this.sqlDataAdapterLogin.InsertCommand = this.sqlInsertCommand1;
    this.sqlDataAdapterLogin.SelectCommand = this.sqlSelectCommand1;
    this.sqlDataAdapterLogin.TableMappings.AddRange&#4 0;new System.Data.Common.DataTableMapping[] {
    new System.Data.Common.DataTableMapping("Table", "registereduser", new System.Data.Common.DataColumnMapping[] {
    new System.Data.Common.DataColumnMapping("userid", "userid"),
    new System.Data.Common.DataColumnMapping("name", "name"),
    new System.Data.Common.DataColumnMapping("password ", "password")})});
    this.sqlDataAdapterLogin.UpdateCommand = this.sqlUpdateCommand1;
    //
    // sqlDeleteCommand1
    //
    this.sqlDeleteCommand1.CommandText = "DELETE FROM registereduser WHERE (name = @Original_name) AND (password = @Origina" +
    "l_password) AND (userid = @Original_userid)";
    this.sqlDeleteCommand1.Connection = this.sqlConnection1;
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ name", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "name", System.Data.DataRowVersion.Original, null));
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ password", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "password", System.Data.DataRowVersion.Original, null));
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ userid", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "userid", System.Data.DataRowVersion.Original, null));
    //
    // sqlInsertCommand1
    //
    this.sqlInsertCommand1.CommandText = "INSERT INTO registereduser(userid, name, password) VALUES (@userid, @name, @passw" +
    "ord); SELECT userid, name, password FROM registereduser WHERE (name = @name)";
    this.sqlInsertCommand1.Connection = this.sqlConnection1;
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@userid", System.Data.SqlDbType.Int, 4, "userid"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.VarChar, 10, "name"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@password" , System.Data.SqlDbType.VarChar, 10, "password"));
    //
    // sqlSelectCommand1
    //
    this.sqlSelectCommand1.CommandText = "SELECT userid, name, password FROM registereduser";
    this.sqlSelectCommand1.Connection = this.sqlConnection1;
    //
    // sqlUpdateCommand1
    //
    this.sqlUpdateCommand1.CommandText = "UPDATE registereduser SET userid = @userid, name = @name, password = @password WH" +
    "ERE (name = @Original_name) AND (password = @Original_password) AND (userid = @O" +
    "riginal_userid); SELECT userid, name, password FROM registereduser WHERE (name =" +
    " @name)";
    this.sqlUpdateCommand1.Connection = this.sqlConnection1;
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@userid", System.Data.SqlDbType.Int, 4, "userid"));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.VarChar, 10, "name"));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@password" , System.Data.SqlDbType.VarChar, 10, "password"));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ name", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "name", System.Data.DataRowVersion.Original, null));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ password", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "password", System.Data.DataRowVersion.Original, null));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ userid", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "userid", System.Data.DataRowVersion.Original, null));
    //
    // dataSetLogin
    //
    this.dataSetLogin.DataSetName = "DataSetLogin";
    this.dataSetLogin.Locale = new System.Globalization.CultureInfo("en-US");
    this.Load += new System.EventHandler(this.Page_Load);
    ((System.ComponentModel.ISupportInitialize )(this.dataSetLogin)).EndInit( );

    }
    #endregion

    private void TextBox2_TextChanged(object sender, System.EventArgs e)
    {

    }

    private void btnLogin_Click(object sender, System.EventArgs e)
    {
    try
    {
    LabelError.Visible=false;
    ImageLoginFail.Visible = false;
    string uid, pwd;
    uid=txtLogin.Text;
    pwd=txtPassword.Text;
    string accessLevel=CheckPassword(uid,pwd);
    if(accessLevel!= "")
    {
    Session["UID"]=uid;
    Session["AccessLevel"]=accessLevel;
    //FormsAuthentication.RedirectFromLoginPage (uid, false);
    string str = (string)(Session["RequestedPage"&# 93;);
    Response.Redirect(str);

    }
    else
    {
    LabelError.Visible=true;
    ImageLoginFail.Visible = true;
    }
    }
    catch (Exception ex)
    {
    ex.ToString();
    }
    }

    private void btnNewUser_Click(object sender, System.EventArgs e)
    {

    }

    private string CheckPassword( string uid, string pwd)
    {
    string connStr="server=guddu;uid=sa;pwd=;database=univers ity";
    SqlConnection conn=new SqlConnection(connStr);

    string sql = "select userid from registereduser where name='" +
    uid + "' and password='"+pwd+"'";
    SqlCommand comm=new SqlCommand(sql, conn);
    conn.Open();
    Object obj = comm.ExecuteScalar();// returns one row
    string userid = "";
    if (obj != null)
    userid = obj.ToString(); // AccessLevel column

    string strRole = "";
    sql = "select role from role where roleid='" +
    userid + "'";
    SqlConnection conn2 = new SqlConnection(connStr);
    SqlCommand comm2 =new SqlCommand(sql, conn2);
    conn2.Open();
    obj = comm2.ExecuteScalar();// returns one row
    if (obj != null)
    strRole = obj.ToString(); // AccessLevel column
    conn2.Close();
    conn.Close();
    return strRole;

    }
    }
    }




    login.aspx.resx




    <?xml version="1.0" encoding="utf-8"?>
    <root>
    <!--
    Microsoft ResX Schema

    Version 1.3

    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.

    Example:

    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">1.3</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1">this is my long string</data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
    [base64 mime encoded serialized .NET Framework object]
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    [base64 mime encoded string representing a byte array form of the .NET Framework object]
    </data>

    There are any number of "resheader" rows that contain simple
    name/value pairs.

    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.

    The mimetype is used forserialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:

    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.

    mimetype: application/x-microsoft.net.object.binary.base64
    value : The object must be serialized with
    : System.Serialization.Formatters.Binary.BinaryForma tter
    : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.soap.base64
    value : The object must be serialized with
    : System.Runtime.Serialization.Formatters.Soap.SoapF ormatter
    : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value : The object must be serialized into a byte array
    : using a System.ComponentModel.TypeConverter
    : and then encoded with base64 encoding.
    -->
    <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:element name="root" msdata:IsDataSet="true">
    <xsd:complexType>
    <xsd:choice maxOccurs="unbounded">
    <xsd:element name="data">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
    <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
    <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
    <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="resheader">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
    </xsd:complexType>
    </xsd:element>
    </xsd:choice>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
    </resheader>
    <resheader name="version">
    <value>1.3</value>
    </resheader>
    <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    <data name="sqlConnection1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>Private</value>
    </data>
    <data name="sqlConnection1.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>172, 17</value>
    </data>
    <data name="sqlDataAdapterLogin.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>Private</value>
    </data>
    <data name="sqlDataAdapterLogin.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
    </data>
    <data name="sqlDeleteCommand1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>Private</value>
    </data>
    <data name="sqlDeleteCommand1.CommandDesignTimeVisible" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>False</value>
    </data>
    <data name="sqlDeleteCommand1.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
    </data>
    <data name="sqlDeleteCommand1.DesignTimeVisible" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>False</value>
    </data>
    <data name="sqlInsertCommand1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>Private</value>
    </data>
    <data name="sqlInsertCommand1.CommandDesignTimeVisible" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>False</value>
    </data>
    <data name="sqlInsertCommand1.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
    </data>
    <data name="sqlInsertCommand1.DesignTimeVisible" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>False</value>
    </data>
    <data name="sqlSelectCommand1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>Private</value>
    </data>
    <data name="sqlSelectCommand1.CommandDesignTimeVisible" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>False</value>
    </data>
    <data name="sqlSelectCommand1.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
    </data>
    <data name="sqlSelectCommand1.DesignTimeVisible" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>False</value>
    </data>
    <data name="sqlUpdateCommand1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>Private</value>
    </data>
    <data name="sqlUpdateCommand1.CommandDesignTimeVisible" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>False</value>
    </data>
    <data name="sqlUpdateCommand1.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
    </data>
    <data name="sqlUpdateCommand1.DesignTimeVisible" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>False</value>
    </data>
    <data name="dataSetLogin.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>299, 17</value>
    </data>
    <data name="dataSetLogin.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>Private</value>
    </data>
    <data name="$this.TrayAutoArrange" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>True</value>
    </data>
    <data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>Private</value>
    </data>
    <data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <value>False</value>
    </data>
    </root>


    global.asax.cs


    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Web;
    using System.Web.SessionState;
    using System.Data.SqlClient;
    using System.Security.Principal;
    namespace University
    {
    /// <summary>
    /// Summary description for Global.
    /// </summary>
    public class Global : System.Web.HttpApplication
    {
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    public Global()
    {
    InitializeComponent();
    }

    protected void Application_Start(Object sender, EventArgs e)
    {

    }

    protected void Session_Start(Object sender, EventArgs e)
    {

    }

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {

    }

    protected void Application_EndRequest(Object sender, EventArgs e)
    {

    }

    protected void Application_Error(Object sender, EventArgs e)
    {

    }

    protected void Session_End(Object sender, EventArgs e)
    {

    }

    protected void Application_End(Object sender, EventArgs e)
    {

    }
    protected void Application_AuthenticateRequest(Object sender, EventArgs e)
    {
    /*
    string connStr="server=local;database=master;integrated security=true;";

    if (Request.IsAuthenticated) // find all roles for this user
    {
    SqlConnection conn = new SqlConnection(connStr);
    conn.Open();
    SqlCommand cmd = new SqlCommand("GetUserRoles",conn);
    cmd.CommandType = System.Data.CommandType.StoredProcedure;
    cmd.Parameters.Add(new SqlParameter("@Username",User.Identity.Name&#4 1;);
    SqlDataReader reader = cmd.ExecuteReader();

    // get the array of user roles
    ArrayList roleList = new ArrayList();
    while(reader.Read())
    roleList.Add(reader["Role"]);

    conn.Close();

    // Convert the roleList ArrayList to a String array
    int i = 0;
    string [] roleListArray = new string[roleList.Count];
    foreach (object o1 in roleList)
    {
    roleListArray[i++] = o1.ToString();
    Response.Write(o1.ToString());
    }

    // Add the roles to the User Principal

    HttpContext.Current.User = new GenericPrincipal(User.Identity, roleListArray);

    }
    */
    }
    #region Web Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.components = new System.ComponentModel.Container();
    }
    #endregion
    }
    }



    global.asax



    <?xml version="1.0" encoding="utf-8" ?>
    <root>
    <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:element name="root" msdata:IsDataSet="true">
    <xsd:complexType>
    <xsd:choice maxOccurs="unbounded">
    <xsd:element name="data">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
    <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" />
    <xsd:attribute name="type" type="xsd:string" />
    <xsd:attribute name="mimetype" type="xsd:string" />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="resheader">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
    </xsd:complexType>
    </xsd:element>
    </xsd:choice>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    <resheader name="ResMimeType">
    <value>text/microsoft-resx</value>
    </resheader>
    <resheader name="Version">
    <value>1.0.0.0</value>
    </resheader>
    <resheader name="Reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    <resheader name="Writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    </root>





    webconfig





    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>

    <system.web>

    <!-- DYNAMIC DEBUG COMPILATION
    Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to
    false will improve runtime performance of this application.
    Set compilation debug="true" to insert debugging symbols (.pdb information)
    into the compiled page. Because this creates a larger file that executes
    more slowly, you should set this value to true only when debugging and to
    false at all other times. For more information, refer to the documentation about
    debugging ASP.NET files.
    -->
    <compilation
    defaultLanguage="C#‎"
    debug="true"
    />

    <!-- CUSTOM ERROR MESSAGES
    Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
    Add <error> tags for each of the errors you want to handle.

    "On" Always display custom (friendly) messages.
    "Off" Always display detailed ASP.NET error information.
    "RemoteOnly" Display custom (friendly) messages only to users not running
    on the local Web server. This setting is recommended for security purposes, so
    that you do not display application detail information to remote clients.
    -->
    <customErrors
    mode="RemoteOnly"
    />

    <!-- AUTHENTICATION
    This section sets the authentication policies of the application. Possible modes are "Windows",
    "Forms", "Passport" and "None"

    "None" No authentication is performed.
    "Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
    its settings for the application. Anonymous access must be disabled in IIS.
    "Forms" You provide a custom form (Web page) for users to enter their credentials, and then
    you authenticate them in your application. A user credential token is stored in a cookie.
    "Passport" Authentication is performed via a centralized authentication service provided
    by Microsoft that offers a single logon and core profile services for member sites.
    -->
    <authentication mode="Forms" >
    <forms loginUrl = "login.aspx" >
    </forms>
    </authentication>
    <!-- AUTHORIZATION
    This section sets the authorization policies of the application. You can allow or deny access
    to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
    (unauthenticated) users.
    -->

    <authorization>
    </authorization>

    <!-- APPLICATION-LEVEL TRACE LOGGING
    Application-level tracing enables trace log output for every page within an application.
    Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
    trace information will be displayed at the bottom of each page. Otherwise, you can view the
    application trace log by browsing the "trace.axd" page from your web application
    root.
    -->
    <trace
    enabled="false"
    requestLimit="10"
    pageOutput="false"
    traceMode="SortByTime"
    localOnly="true"
    />

    <!-- SESSION STATE SETTINGS
    By default ASP.NET uses cookies to identify which requests belong to a particular session.
    If cookies are not available, a session can be tracked by adding a session identifier to the URL.
    To disable cookies, set sessionState cookieless="true".
    -->
    <sessionState
    mode="InProc"
    stateConnectionString="tcpip=127.0.0.1:42424"
    sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
    cookieless="false"
    timeout="20"
    />

    <!-- GLOBALIZATION
    This section sets the globalization settings of the application.
    -->
    <globalization
    requestEncoding="utf-8"
    responseEncoding="utf-8"
    />

    </system.web>

    </configuration>



    با تشکر

  2. #2
    کاربر دائمی آواتار Mahdavi
    تاریخ عضویت
    فروردین 1382
    محل زندگی
    ایران - میگن تهرون
    پست
    606
    یه نگاه کوچولو به سورس مینداختی این همه متن هم اینجا کپی نمی کردی :

    this.sqlConnection1.ConnectionString = "workstation id=GUDDU;packet size=4096;user id=sa;data source=local;persist securi" + 
    "ty info=False;initial catalog=master";


    ولی خودتون هم میبینی که دیتابیس این هم مستره و سرورش Local.
    مشکلت جای دیگس !!!!!

  3. #3
    این کدی که شما نوشتید از کدوم صفحه است؟
    و مثل این کد در چند صفحه است
    کدوم ها رو تغییر بدم؟


    [code]"workstation id=GUDDU;packet size=4096;user id=sa;data source=local;persist securi" +
    "[ty info=False;initial catalog=master"; [/cod

    این packet size وworkstation .. چیه؟
    و آیا میشه دیتا سورس و کاتالوگ رو نوشت؟



    با تشکر

  4. #4
    کاربر دائمی آواتار Mahdavi
    تاریخ عضویت
    فروردین 1382
    محل زندگی
    ایران - میگن تهرون
    پست
    606
    worksation و packet size رو می تونی حذف کنی. اجباری نیست

تاپیک های مشابه

  1. تفاوت Response.Redirect با Server.Transfer و Server.Execute
    نوشته شده توسط odiseh در بخش Classic ASP
    پاسخ: 2
    آخرین پست: یک شنبه 18 بهمن 1388, 20:13 عصر
  2. Link Server & Import Data In SQL Server 2000
    نوشته شده توسط A.Farzin در بخش SQL Server
    پاسخ: 3
    آخرین پست: شنبه 01 دی 1386, 13:53 عصر
  3. طای HTTP/1.1 500 Server Error Server: Microsoft-IIS/5.1 Date...
    نوشته شده توسط nak303 در بخش PHP
    پاسخ: 0
    آخرین پست: سه شنبه 25 بهمن 1384, 10:02 صبح
  4. پیغام خطا پس از نصبSQL Server 2000 روی Windows Server 2003
    نوشته شده توسط ravanfar در بخش SQL Server
    پاسخ: 1
    آخرین پست: پنج شنبه 03 دی 1383, 23:41 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •