本文整理汇总了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;
}
}
示例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");
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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";
}
示例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();
}
示例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");
}
示例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()));
}
}
}
}
示例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;
}
}
示例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;
}
}
示例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();
}
示例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");
}
示例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;
}