当前位置: 首页>>代码示例>>C#>>正文


C# SqlDataSource.Select方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.SqlDataSource.Select方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataSource.Select方法的具体用法?C# SqlDataSource.Select怎么用?C# SqlDataSource.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.SqlDataSource的用法示例。


在下文中一共展示了SqlDataSource.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Load_Logo();

            string connectionstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            SqlDataSource1.SelectCommand = "Select LIST_NAME from LIST";
            SqlDataSource1.Select(DataSourceSelectArguments.Empty);
            //SqlConnection con = new SqlConnection(@"Data Source=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;");
            //SqlCommand cmd = new SqlCommand("Select LIST_NAME from LIST", con);
            //SqlDataAdapter adp = new SqlDataAdapter(cmd);
            //DataTable dt = new DataTable();
            //adp.Fill(dt);
            //listCheckBox.DataSource = dt;
            //listCheckBox.DataValueField = "LIST_NAME";
            //listCheckBox.DataBind();

            connectionstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selectstring = "SELECT ADMIN_SECURITYCODE FROM ADMINISTRATOR WHERE USER_ID = 0";
            SqlDataSource database = new SqlDataSource(connectionstring, selectstring);
            DataView dv = (DataView)database.Select(DataSourceSelectArguments.Empty);
            string code = (string)dv.Table.Rows[0][0];

            if (code == "No Code Set")
            {
                organizationCodeBox.Visible = false;
                Label1.Visible = false;
            }
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:28,代码来源:TextAlertRegistration.aspx.cs

示例2: Button1_Click

        protected void Button1_Click(object sender, EventArgs e)
        {
            // verify login credentials
            string EmailAddress = TextBox1.Text;
            string Password = TextBox2.Text;

            string connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selstring = "SELECT * FROM SENDER";
            SqlDataSource db = new SqlDataSource(connstring, selstring);
            DataView dv = (DataView)db.Select(DataSourceSelectArguments.Empty);
            int count = dv.Table.Rows.Count;
            string email = (string)dv.Table.Rows[0][1];
            string password = (string)dv.Table.Rows[0][2];
            int i = 0;
            bool status = false;
            while (i < count)
            {
                email = (string)dv.Table.Rows[i][1];
                password = (string)dv.Table.Rows[i][2];
                if (EmailAddress == email && Password == password)
                {
                    Session["username"] = EmailAddress;
                    Response.Redirect("text-message-page.aspx");
                    status = true;
                }
                else status = false;
                i++;
            }
            if (status == false)
            {
                Response.Redirect("SendMessagePage.aspx");
            }
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:33,代码来源:SendMessagePage.aspx.cs

示例3: Load_Logo

        private void Load_Logo()
        {
            string connectionstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selectstring = "SELECT ADMIN_LOGONAME FROM ADMINISTRATOR WHERE USER_ID = 0";

            SqlDataSource database = new SqlDataSource(connectionstring, selectstring);
            DataView dv = (DataView)database.Select(DataSourceSelectArguments.Empty);
            string filename = (string)dv.Table.Rows[0][0];

            if (System.IO.File.Exists(Server.MapPath("~/Content/") + filename) == true)
            {
                LogoImage.ImageUrl = "~/Content/" + filename;
            }
            else
            {
                LogoImage.ImageUrl = "~/Content/" + "evansville_day_school.jpg";

                string connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
                string selstring = "SELECT * FROM ADMINISTRATOR WHERE USER_ID = 0";
                string updatestring = "UPDATE ADMINISTRATOR SET ADMIN_LOGONAME = 'evansville_day_school.jpg' WHERE USER_ID = 0";
                SqlDataSource db = new SqlDataSource(connstring, selstring);
                db.UpdateCommand = updatestring;
                db.Update();
            }

            dv.Dispose();
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:27,代码来源:ManageListPage.aspx.cs

示例4: GridView1_SelectedIndexChanged

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlDataSource sds = new SqlDataSource(ConfigurationManager.ConnectionStrings["cs"].ConnectionString, "SELECT * FROM [users] WHERE [username]='" + GridView1.SelectedValue + "'");

            DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty);

            TextBox1.Text = dv[0].Row[0].ToString();
            TextBox2.Text = dv[0].Row[1].ToString();
            TextBox3.Text = dv[0].Row[2].ToString();
        }
开发者ID:kaizeth,项目名称:custom-database-test,代码行数:10,代码来源:manage.aspx.cs

示例5: OnLoad

 protected void OnLoad(object sender, EventArgs e)
 {
     DateTime d=DateTime.Parse(Session["date"].ToString());
     int jour = Int16.Parse(Session["jour"].ToString());
     DateTime dfin = d.AddDays(jour);
     availdatasource = new SqlDataSource();
     availdatasource.ConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
     availdatasource.Select(new DataSourceSelectArguments());
     availdatasource.SelectParameters["datedebut"].DefaultValue = d.ToShortDateString();
     availdatasource.SelectParameters["datefin"].DefaultValue = dfin.ToShortDateString();
     repet.DataBind();
 }
开发者ID:natavi,项目名称:hotelrichardweb,代码行数:12,代码来源:inter.aspx.cs

示例6: CategorieName

        //ameliorer pour tout type de int, string; etc avec typeof???
        protected string CategorieName(SqlDataSource DataSource, DataRowView nom, string ID, string Name)
        {
            NewVar = (DataView)DataSource.Select(DataSourceSelectArguments.Empty);

            DataRow ligne = nom.Row;

            int CatName = (int)ligne[ID];

            NewVar.RowFilter = ID + " = " + CatName;

            return NewVar[0][Name].ToString();
        }
开发者ID:boule46,项目名称:activite_git,代码行数:13,代码来源:AmeliorerPresentation.aspx.cs

示例7: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Load_Logo();

            string connectionstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selectstring = "SELECT ADMIN_TOKENS FROM ADMINISTRATOR";

            SqlDataSource database = new SqlDataSource(connectionstring, selectstring);
            DataView dv = (DataView)database.Select(DataSourceSelectArguments.Empty);
            string tokens = Convert.ToString((dv.Table.Rows[0][0]));
            Label1.Text = tokens;
            Label2.Text = "https://www.notarealwebsite/CS478";
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:13,代码来源:AccountInformationPage.aspx.cs

示例8: saveButtonClick

        protected void saveButtonClick(object sender, EventArgs e)
        {
            string connectionstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selectstring = "SELECT MAX(SENDER_ID) FROM SENDER";
            SqlDataSource database = new SqlDataSource(connectionstring, selectstring);
            DataView dv = (DataView)database.Select(DataSourceSelectArguments.Empty);
            int maxid = (int)dv.Table.Rows[0][0];

            String email = emailTextBox.Text;
            int id = maxid + 1;
            SqlDataSource1.InsertCommand = string.Format("INSERT INTO SENDER (SENDER_ID, SENDER_EMAIL, SENDER_PASSWORD) VALUES({0},'{1}','{2}')", id, email, pinTextBox.Text);

            SqlDataSource1.Insert();
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:14,代码来源:ManageSenders.aspx.cs

示例9: Button1_Click

        protected void Button1_Click(object sender, EventArgs e)
        {
            // Data source control that works with Sql databases

            SqlDataSource sds = new SqlDataSource();

            // Get connection string from application's default configuration

            sds.ConnectionString = ConfigurationManager.ConnectionStrings["E-Global"].ToString();

            // Create parameters with specified names and values

            sds.SelectParameters.Add("Username", TypeCode.String, this.TextBox1.Text);

            sds.SelectParameters.Add("Password", TypeCode.String, getMD5(this.TextBox2.Text));

            // Set the SQL string to retrieve data from the underlying database

            sds.SelectCommand = "SELECT * FROM [UserTable] WHERE [Username] = @Username AND [Password] = @Password";

            // Retrieve data

            DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty);

            if (dv.Count == 0)
            {

                this.Label1.ForeColor = System.Drawing.Color.Red;

                this.Label1.Text = "Login Failed!";

                return;

            }

            this.Session["Username"] = dv[0].Row["Username"].ToString();

            this.Session["UserType"] = dv[0].Row["UserType"].ToString();

            if (this.Session["UserType"].ToString().Equals("user"))

                Response.Redirect("UserMain.aspx");

            else if (this.Session["UserType"].ToString().Equals("admin"))

                Response.Redirect("MainPageAdmin.aspx");
        }
开发者ID:Bedi22,项目名称:C-Online-Shopping-web-application,代码行数:47,代码来源:Login.aspx.cs

示例10: ddl_Category_SelectedIndexChanged

    protected void ddl_Category_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddl_Category2.Items.Clear();

        using (var DS = new System.Web.UI.WebControls.SqlDataSource())
        {
            DS.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["AdventureWorksConnectionString"].ConnectionString;
            DS.SelectCommand = "select ProductCategoryID, Name from ProductCategory where ParentProductCategoryID = " + ddl_Category.SelectedValue + " order by Name";
            using (var result = (DS.Select(System.Web.UI.DataSourceSelectArguments.Empty) as System.Data.DataView).Table)
            {
                foreach (DataRow row in result.Rows)
                {
                    ddl_Category2.Items.Add(new ListItem(row["Name"].ToString(), row["ProductCategoryID"].ToString()));
                }
            }
        }
    }
开发者ID:kingkongkbf,项目名称:AdvASPdotNetCourse,代码行数:17,代码来源:original.aspx.cs

示例11: Button1_Click

        protected void Button1_Click(object sender, EventArgs e)
        {
            string connectionstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selectstring = "SELECT ADMIN_USERNAME, ADMIN_PASSWORD FROM ADMINISTRATOR WHERE USER_ID = 0";

            SqlDataSource database = new SqlDataSource(connectionstring, selectstring);
            DataView dv = (DataView)database.Select(DataSourceSelectArguments.Empty);
            string username = (string)dv.Table.Rows[0][0];
            string password = (string)dv.Table.Rows[0][1];

            if (usernametextbox.Text == username & passwordtextbox.Text == password)
            {
                Server.Transfer("OrganizationManagement.aspx");
            }
            else
            {
                Label1.Text = "Wrong user/password.";
                Label1.ForeColor = System.Drawing.Color.Red;
            }
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:20,代码来源:AdminLogin.aspx.cs

示例12: Button1_Click

        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlDataSource sds = new SqlDataSource();
            sds.ConnectionString = ConfigurationManager.ConnectionStrings["E-Global"].ToString();

            sds.SelectParameters.Add("Username", TypeCode.String, this.txtUserName.Text);
            sds.SelectParameters.Add("Email", TypeCode.String, this.txtEmail1.Text);

            sds.SelectCommand = "SELECT * FROM [UserTable] WHERE [Username] = @Username OR [Email] = @Email";

            DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty);

            if (dv.Count != 0)
            {

                this.Label1.ForeColor = System.Drawing.Color.Red;

                this.Label1.Text = "The user already Exist!";

                return;

            }

            else
            {

                this.SqlDataSource2.Insert();
                this.Label1.Text = "New User Profile has been created you can login now";
                Button1.Enabled = false;
                txtAddress.Enabled = false;
                txtEmail1.Enabled = false;
                txtEmail2.Enabled = false;
                txtName.Enabled = false;
                txtPassword1.Enabled = false;
                txtpassword2.Enabled = false;
                txtUserName.Enabled = false;
            }
        }
开发者ID:Bedi22,项目名称:C-Online-Shopping-web-application,代码行数:38,代码来源:AdminUserMaintain.aspx.cs

示例13: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Load_Logo();

            string connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selstring = "SELECT ADMIN_SECURITYCODE FROM ADMINISTRATOR WHERE USER_ID = 0";
            SqlDataSource db = new SqlDataSource(connstring, selstring);
            DataView dv = (DataView)db.Select(DataSourceSelectArguments.Empty);

            string code;
            try
            {
                code = (string)dv.Table.Rows[0][0];
            }
            catch (Exception)
            {
                code = "No Code Set";
            }

            Label2.Text = "Current Code: " + code;

            dv.Dispose();
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:23,代码来源:Organization+Security+Code+Page.aspx.cs

示例14: Button1_Click

        protected void Button1_Click(object sender, EventArgs e)
        {
            string connstring = "Server=tcp:evansvilledayschoolserver.database.windows.net,1433;Database=EvansvilleDaySchoolDatabase;User [email protected];Password=Quokka12;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            string selstring = "SELECT * FROM SUBSCRIPTION JOIN USERS ON USERS.USER_ID = SUBSCRIPTION.USER_ID JOIN LIST ON SUBSCRIPTION.LIST_ID =  LIST.LIST_ID";

            string phone = Label1.Text + Label4.Text + Label5.Text;
            string fname = Label2.Text;
            string lname = Label3.Text;
            string lists = Label6.Text;

            SqlDataSource db = new SqlDataSource(connstring, selstring);
            DataView dv = (DataView)db.Select(DataSourceSelectArguments.Empty);
            string FirstName = (string)dv.Table.Rows[0][4];
            string LastName = (string)dv.Table.Rows[0][5];
            string Phone = (string)dv.Table.Rows[0][6];
            int userid = (int)dv.Table.Rows[0][0];
            string updatestring = String.Format("UPDATE USERS SET USER_FNAME={0}, USER_LNAME={1}, USER_PHONE={2} WHERE USER_ID={3};", fname, lname, phone, userid);
            db.UpdateCommand = updatestring;
            //db.InsertCommand = insertstring;

            if (FirstName == Label2.Text && LastName == Label3.Text)
            {
                string firstUpdateString = String.Format("UPDATE USERS SET USER_FNAME={0}, USER_LNAME={1}, USER_PHONE={2} WHERE USER_ID={3};", fname, lname, phone, userid);
                db.UpdateCommand = updatestring;
                db.Update();
            }
            else
            {
                string insertstring = String.Format("INSERT INTO USERS VALUES {0},{1},{2}", fname, lname, phone);
                db.Insert();
                insertstring = String.Format("INSERT INTO SUBSCRIPTION VALUES {0}", lists);
                db.InsertCommand = insertstring;
                db.Insert();
            }

            Response.Redirect("TextAlertRegistration.aspx");
        }
开发者ID:usiwallaby,项目名称:CS478-RelayEngine,代码行数:37,代码来源:regConf.aspx.cs

示例15: ReturnedResultRowCount

 // returns a count of the number of results returned by an sql datasource.
 // @params: SqlDataSource
 public static int ReturnedResultRowCount(SqlDataSource dataSource)
 {
     DataView result = (DataView)dataSource.Select(DataSourceSelectArguments.Empty);
     return result.Count;
 }
开发者ID:Machiaveli,项目名称:Tech_Support_v2,代码行数:7,代码来源:customers.aspx.cs


注:本文中的System.Web.UI.WebControls.SqlDataSource.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。