本文整理汇总了C#中SqlDataSource类的典型用法代码示例。如果您正苦于以下问题:C# SqlDataSource类的具体用法?C# SqlDataSource怎么用?C# SqlDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlDataSource类属于命名空间,在下文中一共展示了SqlDataSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: btnUpdate_Click
//按鈕更新
protected void btnUpdate_Click(object sender, EventArgs e)
{
//壓縮圖片並存檔
CImageProess.get().UploadImage(FileUpload1, 資料夾路徑, CDictionary.SET_BRAND_PX);
x = new SqlDataSource();
x.ConnectionString = CDictionary.CONN_URL;
string sql = "UPDATE Company set ";
if (!string.IsNullOrEmpty(txtContent.Text))
{
sql += " name=N'" + txtName.Text + "', ";
if (FileUpload1.HasFile)
sql += " picBrandPath='" + CImageProess.imageName + "', ";
sql += " manager=N'" + txtManager.Text + "', ";
sql += " tel=N'" + txtPhone.Text + "', ";
sql += " sparEmail=N'" + txtSpareEmail.Text + "', ";
sql += " addr=N'" + txtAddress.Text + "', ";
sql += " content=N'" + txtContent.Text + "' ";
sql += "WHERE companyID='" + companyID + "'";
x.UpdateCommand = sql;
x.Update();
}
else
return;
Response.Write("<script>alert('更改資料成功!')</script>");
Response.Write("<script>location.href='companyCheck.aspx'</script>");
}
开发者ID:CYHuangMike,项目名称:Collections,代码行数:31,代码来源:companyDetail.aspx.cs
示例2: btnAdd_Click
protected void btnAdd_Click(object sender, EventArgs e)
{
SqlDataSource sql1 = new SqlDataSource();
sql1 = SqlDataSource1;
SqlDataSource1.InsertParameters["Course_id"].DefaultValue = TextBox3.Text;
SqlDataSource1.InsertParameters["Assignment"].DefaultValue = TextBox8.Text;
SqlDataSource1.InsertParameters["Subject_id"].DefaultValue = TextBox4.Text;
SqlDataSource1.InsertParameters["Instructor"].DefaultValue = TextBox5.Text;
SqlDataSource1.InsertParameters["Instructor_rank"].DefaultValue = Convert.ToString(TextBox6.Text);
SqlDataSource1.InsertParameters["Due_Date"].DefaultValue = TextBox9.Text;
try
{
SqlDataSource1.Insert();
TextBox3.Text = "";
TextBox8.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox9.Text = "";
}
catch (Exception ex)
{
lblError.Text = "A DB error has occurred. " + "Message: " + ex.Message;
}
}
开发者ID:cweber-wou,项目名称:capstone,代码行数:26,代码来源:EditPage.aspx.cs
示例3: DetailsView_Route_has_Bus_ItemUpdating
protected void DetailsView_Route_has_Bus_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
String Route_has_Bus_ID = DetailsView_Route_has_Bus.SelectedValue.ToString();
DropDownList D_Bus_ID_NEW = (DropDownList)DetailsView_Route_has_Bus.FindControl("DropDownList3");
DropDownList D_Bus_ID_OLD = (DropDownList)DetailsView_Route_has_Bus.FindControl("DropDownList7");
String Bus_ID_NEW = D_Bus_ID_NEW.SelectedValue;
String Bus_ID_OLD = D_Bus_ID_OLD.SelectedValue;
if (Bus_ID_NEW != Bus_ID_OLD)
{
delete_seat(Route_has_Bus_ID);
SqlDataSource seat = new SqlDataSource();
seat.ConnectionString =
ConfigurationManager.ConnectionStrings["BusTicketConnectionString1"].ToString();
String count_seat = get_seat_count(Bus_ID_NEW).ToString();
String command = "";
command = get_insert_command(count_seat, Route_has_Bus_ID);
if (command != "")
{
String insertCommand = "INSERT INTO [Seat] "
+ " (Route_has_Bus_ID, Seat_Number, Seat_Name, Seat_Status) "
+ " VALUES "
+ command
+ ";";
seat.InsertCommand = insertCommand;
seat.Insert();
}
}
}
开发者ID:chagridsada,项目名称:BusTicket-Online,代码行数:33,代码来源:Route_has_Bus.aspx.cs
示例4: DetailsView_Route_has_Bus_ItemInserted
protected void DetailsView_Route_has_Bus_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
DropDownList BS = (DropDownList)DetailsView_Route_has_Bus.FindControl("DropDownList5");
SqlDataSource seat = new SqlDataSource();
seat.ConnectionString =
ConfigurationManager.ConnectionStrings["BusTicketConnectionString1"].ToString();
String count_seat = get_seat_count(BS.SelectedValue).ToString();
String command = "";
String Route_has_Bus_ID = get_Route_has_Bus_ID_Last().ToString();
command = get_insert_command(count_seat, Route_has_Bus_ID);
if (command != "")
{
String insertCommand = "INSERT INTO [Seat] "
+ " (Route_has_Bus_ID, Seat_Number, Seat_Name, Seat_Status) "
+ " VALUES "
+ command
+ ";";
seat.InsertCommand = insertCommand;
seat.Insert();
}
Response.Redirect(Request.RawUrl);
}
开发者ID:chagridsada,项目名称:BusTicket-Online,代码行数:27,代码来源:Route_has_Bus.aspx.cs
示例5: Login1_Authenticate
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string conString = "Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\Yummy.mdf;Integrated Security=True";
string selectString = "SELECT * FROM tb_Userinfo WHERE Username='" + Login1.UserName + "'";//select string for search currency name correspond with the input
SqlDataSource dsrc = new SqlDataSource(conString, selectString);
DataView DV = (DataView)dsrc.Select(DataSourceSelectArguments.Empty);
if (DV.Table.Rows.Count > 0)
{
string password = (string)DV.Table.Rows[0][7];
if (password.Equals(Login1.Password))
{
//Label1.Text = "Congratulations! Login succeed! Please wait for redirect to Homepage!";
Session["Username"] = Login1.UserName;
Session["Call"] = DV.Table.Rows[0][1].ToString();
Server.Transfer("~/WebSite2/Default.aspx");
//Response.Write("<script language=javascript>alert('Congratulations! Login succeed!')</script>");
//System.Threading.Thread.Sleep(5000);
//Response.Redirect("~/WebSite2/Default.aspx");
}
else
e.Authenticated = false;
}
else
e.Authenticated = false;
}
开发者ID:Tommyhank,项目名称:UIinterface,代码行数:25,代码来源:Login.aspx.cs
示例6: FrmDataSourceWizard_Load
private void FrmDataSourceWizard_Load(object sender, EventArgs e)
{
var sds = new SqlDataSource("ConnectionString");
var ccc = new ConfigureConnectionContext();
SqlDataSourceUIHelper.ConfigureConnection(sds, ccc);
}
开发者ID:Refactoring,项目名称:CIIP,代码行数:7,代码来源:FrmDataSourceWizard.cs
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
String userName = Session["Username"].ToString();
string conString = "Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\Yummy.mdf;Integrated Security=True";
string selectString = "SELECT * FROM [tb_Userinfo] WHERE Username='" + userName + "'";//select string for search currency name correspond with the input
SqlDataSource dsrc = new SqlDataSource(conString, selectString);
DataView DV = (DataView)dsrc.Select(DataSourceSelectArguments.Empty);
username.Text = DV.Table.Rows[0][6].ToString();
Call.Text = DV.Table.Rows[0][1].ToString();
email.Text = DV.Table.Rows[0][3].ToString();
Phone.Text = DV.Table.Rows[0][5].ToString();
if(DV.Table.Rows[0][2].ToString()=="Male")
RadioGenderList.Items[0].Selected=true;
else
RadioGenderList.Items[1].Selected = true;
switch (DV.Table.Rows[0][4].ToString())
{
case "BuCentral": RadioAreaList.Items[1].Selected = true; break;
case "BuWest": RadioAreaList.Items[0].Selected = true; break;
case "BuEast": RadioAreaList.Items[2].Selected = true; break;
case "BuOther": RadioAreaList.Items[3].Selected = true; break;
}
Register.Text = "Update";
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
开发者ID:Tommyhank,项目名称:UIinterface,代码行数:31,代码来源:Register.aspx.cs
示例8: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
SqlDataSource sqldatasource2 = new SqlDataSource();
sqldatasource2.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
sqldatasource2.UpdateParameters.Add("Order_date", TextBox1.Text);
sqldatasource2.UpdateParameters.Add("Assign_numbers", TextBox2.Text);
sqldatasource2.UpdateParameters.Add("Account_numbers", DropDownList1.Text);
sqldatasource2.UpdateParameters.Add("Account_abstract", TextBox3.Text);
sqldatasource2.UpdateParameters.Add("Income", TextBox4.Text);
sqldatasource2.UpdateParameters.Add("Spend", TextBox5.Text);
sqldatasource2.UpdateCommand = "Update [Account_Order_M] set [email protected]_date, [email protected]_numbers, [email protected]_numbers, [email protected]_abstract, [email protected], [email protected] where Id="+Request["Id"];
int affraw_update = sqldatasource2.Update();
if (affraw_update == 0)
{
Label1.Text = "error";
}
else
{
Label1.Text = "ok";
Button1.Visible = false;
}
sqldatasource2.Dispose();
}
开发者ID:keithliang,项目名称:PersonalProducts_Account,代码行数:25,代码来源:UpdateJournalUpdate.aspx.cs
示例9: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
SqlDataSource SqlDataSource2 = new SqlDataSource();
SqlDataSource2.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
try
{
SqlDataSource2.DeleteCommand = "delete [Account_Order_M] where id=" + Request["Id"];
int affraw = SqlDataSource2.Delete();
if (affraw == 0)
{
Label8.Text = "error";
Button1.Visible = false;
}
else
{
Label8.Text = "ok";
Button1.Visible = false;
}
}
catch (Exception ex2)
{
Response.Write(ex2.ToString());
}
finally
{
SqlDataSource2.Dispose();
}
}
开发者ID:keithliang,项目名称:PersonalProducts_Account,代码行数:29,代码来源:UpdateJournalDelate.aspx.cs
示例10: excuteNonQuery
private void excuteNonQuery(string sql)
{
SqlDataSource x = new SqlDataSource();
x.ConnectionString = @"Data Source=iii0.database.windows.net;Initial Catalog=prjTRK;Persist Security Info=True;User ID=iii;[email protected]";
x.InsertCommand = sql;
x.Insert();
Response.Redirect("~/windowCompany/companyCheck.aspx");
}
开发者ID:CYHuangMike,项目名称:Collections,代码行数:8,代码来源:news.aspx.cs
示例11: delete_seat
protected void delete_seat(String Route_has_Bus_ID)
{
SqlDataSource seat = new SqlDataSource();
seat.ConnectionString =
ConfigurationManager.ConnectionStrings["BusTicketConnectionString1"].ToString();
seat.DeleteCommand = "DELETE FROM [Seat] WHERE Route_has_Bus_ID = " + Route_has_Bus_ID;
seat.Delete();
}
开发者ID:chagridsada,项目名称:BusTicket-Online,代码行数:8,代码来源:Route_has_Bus.aspx.cs
示例12: DeleteBtn_Click
protected void DeleteBtn_Click(object sender, EventArgs e)
{
//ɾ���ݸ�
int formID = (int)this.ViewState["ObjectId"];
this.PersonalReimburseBLL.DeleteFormTravelReimburse(formID);
this.Page.Response.Redirect("~/Home.aspx");
SqlDataSource sds = new SqlDataSource();
}
开发者ID:hijoy,项目名称:VSL_ERS,代码行数:8,代码来源:TravelReimburseApply.aspx.cs
示例13: LinkButton2_Click
protected void LinkButton2_Click(object sender, EventArgs e)
{
int code = Convert.ToInt32((sender as LinkButton).ToolTip.ToString());
string sql = "select (select top 1 m_fa_name from tbl_modules where m_id = tbl_groups_permission.gd_module_link) as [نام ماژول] , gd_blocked as [قفل] from tbl_groups_permission where tbl_groups_permission.gd_tbl_groups_link = " + code.ToString() + " order by gd_blocked desc";
SqlDataSource sds = new SqlDataSource(new main_class().get_connection_string(), sql);
GridView4.DataSource = sds;
GridView4.DataBind();
}
开发者ID:bahmany,项目名称:barIran,代码行数:8,代码来源:frm_permission_manager.ascx.cs
示例14: Bind
private void Bind()
{
SqlDataSource SqlDataSource1 = new SqlDataSource();
this.Page.Controls.Add(SqlDataSource1);
SqlDataSource1.ConnectionString = "Data Source=W8-RKOEN;Initial Catalog=PrinterMigration;User ID=sa;[email protected]";
SqlDataSource1.SelectCommand = "SELECT * FROM Main Order By Floor";
GridView1.DataSource = SqlDataSource1;
GridView1.DataBind();
}
开发者ID:jlam916,项目名称:ServiceDesk,代码行数:9,代码来源:Printer_Migration_Status_Page.aspx.cs
示例15: executeQuery
private void executeQuery()
{
x = new SqlDataSource();
x.ConnectionString = @"Data Source=iii0.database.windows.net;Initial Catalog=prjTRK;Persist Security Info=True;User ID=iii;[email protected]";
x.SelectCommand = "Select * from Company where companyID='" + companyID + "'";
DataView dv = x.Select(DataSourceSelectArguments.Empty) as DataView;
txtCounterInput.Text = dv.Table.Rows[0]["name"].ToString();
}
开发者ID:CYHuangMike,项目名称:Collections,代码行数:9,代码来源:news.aspx.cs
示例16: GetData
private void GetData()
{
//第一步
SqlDataSource dataSource = new SqlDataSource();
dataSource.ConnectionString = "server=.;database=schooldb;uid=ASPNET;pwd=ASPNET";
dataSource.SelectCommand = "SELECT * FROM Student";
dgvStudent.DataSource = dataSource;
dgvStudent.DataBind();
//第一步
}
开发者ID:ningboliuwei,项目名称:Course_ASPNET,代码行数:10,代码来源:DataSourceBasicExample.aspx.cs
示例17: AddButton_Click
protected void AddButton_Click(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
conn.Open();
String insert = "insert into Vehicle (Make, Model, Color, Year, LicensePlate, Valid) VALUES(@Make, @Model, @Color, @Year, @LicensePlate, @Valid)";
SqlCommand com3 = new SqlCommand(insert, conn);
com3.Parameters.AddWithValue("@Make", MakeTextBox.Text.Trim());
com3.Parameters.AddWithValue("@Model", ModelTextBox.Text.Trim());
com3.Parameters.AddWithValue("@Color", ColorTextBox.Text.Trim());
com3.Parameters.AddWithValue("@Year", YearTextBox.Text.Trim());
com3.Parameters.AddWithValue("@LicensePlate", LicenseTextBox.Text.Trim());
com3.Parameters.AddWithValue("@Valid", 1);
com3.ExecuteNonQuery();
String insert2 = "insert into VehicleList (VehicleID, PersonalID) VALUES(@LicensePlate, " + Session["New"] + ")";
SqlCommand com = new SqlCommand(insert2, conn);
com.Parameters.AddWithValue("@LicensePlate", LicenseTextBox.Text.Trim());
com.ExecuteNonQuery();
StatusLabel.ForeColor = System.Drawing.Color.Green;
StatusLabel.Text = "Vehicle registered sucessfully";
String insert3 = "insert into Decal (VehicleID, ExpirationDate, PersonalID) VALUES(@LicensePlate, @Date, @PID)";
SqlCommand com2 = new SqlCommand(insert3, conn);
com2.Parameters.AddWithValue("@LicensePlate", LicenseTextBox.Text.Trim());
com2.Parameters.Add("@Date", DateTime.Now);
com2.Parameters.Add("@PID", Session["New"]);
com2.ExecuteNonQuery();
SqlDataSource SqlDataSource1 = new SqlDataSource();
SqlDataSource1.ID = "SqlDataSource1";
this.Page.Controls.Add(SqlDataSource1);
SqlDataSource1.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString;
SqlDataSource1.SelectCommand = "select vl.VehicleID, v.Make, v.Model, v.Color, v.Year from VehicleList vl, Vehicle v where v.LicensePlate = vl.VehicleID and PersonalID = " + SessionLabel.Text.Trim();
GridView1.DataSource = SqlDataSource1;
GridView1.DataBind();
SqlConnection conn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
conn2.Open();
string vehiclesQuery = "SELECT COUNT(VehicleID) FROM VehicleList where PersonalID='" + Session["New"] + "'";
SqlCommand pass4 = new SqlCommand(vehiclesQuery, conn2);
string vCount = pass4.ExecuteScalar().ToString().Replace(" ", "");
if (Int32.Parse(vCount) == 0)
{
NoVehiclesLabel.Text = "You do not have any vehicles registered!";
}
conn2.Close();
}
catch(Exception)
{
StatusLabel.ForeColor = System.Drawing.Color.Red;
StatusLabel.Text = "The vehicle is already registered";
}
}
开发者ID:CSCI540,项目名称:CSCI540,代码行数:54,代码来源:AddNewVehicle.aspx.cs
示例18: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
RestaurantName = Session["Restaurantname"].ToString();
LabelRname.Text = RestaurantName;
//Session.Remove("Restaurantname");
Image1.ImageUrl = "~/WebSite2/Image/BU Central/" + RestaurantName + ".jpg";
string conString = "Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\Yummy.mdf;Integrated Security=True";
string selectString = "SELECT * FROM tb_Restaurant WHERE Name='" + RestaurantName +"'";//select string for search currency name correspond with the input
SqlDataSource dsrc = new SqlDataSource(conString, selectString);
DataView DV = (DataView)dsrc.Select(DataSourceSelectArguments.Empty);
LabelAddress.Text = DV.Table.Rows[0][2].ToString();
LabelContact.Text = DV.Table.Rows[0][3].ToString();
LabelCuisine.Text = DV.Table.Rows[0][4].ToString();
float a = float.Parse(DV.Table.Rows[0][5].ToString());
float b = (float)(Math.Round(a * 100)) / 100;
LabelRate.Text = b.ToString();
LabelDescription.Text = DV.Table.Rows[0][7].ToString();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
try
{
UserName = Session["Username"].ToString();
UserCall = Session["Call"].ToString();
string conString = "Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\Yummy.mdf;Integrated Security=True";
string selectString = "SELECT * FROM tb_Review WHERE Uname='" + UserCall + "' AND Rname='" + RestaurantName + "'";//select string for search currency name correspond with the input
SqlDataSource dsrc = new SqlDataSource(conString, selectString);
DataView DV = (DataView)dsrc.Select(DataSourceSelectArguments.Empty);
if (DV.Table.Rows.Count > 0)
{
LabelReviewRate.Visible = false;
LabelReviewContent.Visible = false;
TextBoxRate.Visible = false;
TextBox1.Visible = false;
Button1.Visible = false;
}
}
catch (Exception ex)
{
LabelReviewRate.Visible = false;
LabelReviewContent.Visible = false;
TextBoxRate.Visible = false;
TextBox1.Visible = false;
Button1.Visible = false;
Console.WriteLine(ex.ToString());
}
}
开发者ID:Tommyhank,项目名称:UIinterface,代码行数:54,代码来源:Restaurant.aspx.cs
示例19: getSelectChildren
protected SqlDataSource getSelectChildren(string entity)
{
string selectCommand = "[CTX].[sp_Select_Child_Entities]";
parent = new Parameter("entity_id");
parent.DefaultValue = entity;
SqlDataSource sds = new SqlDataSource(ConfigurationManager.ConnectionStrings["dlgf"].ConnectionString, selectCommand);
sds.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
sds.CancelSelectOnNullParameter = false;
sds.SelectParameters.Add(parent);
return sds;
}
开发者ID:243,项目名称:ConTAX,代码行数:12,代码来源:DropDownNode.cs
示例20: gridViewMaster_RowDataBound
protected void gridViewMaster_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string customerID = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "CustomerID"));
GridView gridViewNested = (GridView)e.Row.FindControl("nestedGridView");
SqlDataSource sqlDataSourceNestedGrid = new SqlDataSource();
sqlDataSourceNestedGrid.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
sqlDataSourceNestedGrid.SelectCommand = "SELECT [OrderID], [OrderDate],[Freight] FROM [Orders] WHERE [CustomerID] = '" + customerID + "'";
gridViewNested.DataSource = sqlDataSourceNestedGrid;
gridViewNested.DataBind();
}
}
开发者ID:hpie,项目名称:hpie,代码行数:13,代码来源:Default.aspx.cs
注:本文中的SqlDataSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论