本文整理汇总了C#中DataSet类的典型用法代码示例。如果您正苦于以下问题:C# DataSet类的具体用法?C# DataSet怎么用?C# DataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataSet类属于命名空间,在下文中一共展示了DataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSmtpSettings
public DataSet GetSmtpSettings()
{
DataSet dsSmtp = new DataSet();
SqlConnection SqlCon = new SqlConnection(ConStr);
try
{
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.Connection = SqlCon;
sqlCmd.CommandText = "sp_Get_SmtpSettings";
sqlCmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dsSmtp);
}
catch (SqlException SqlEx)
{
objNLog.Error("SQLException : " + SqlEx.Message);
throw new Exception("Exception re-Raised from DL with SQLError# " + SqlEx.Number + " while Inserting SMTP Settings.", SqlEx);
}
catch (Exception ex)
{
objNLog.Error("Exception : " + ex.Message);
throw new Exception("**Error occured while Inserting SMTP Settings.", ex);
}
finally
{
SqlCon.Close();
}
return dsSmtp;
}
示例2: EnsureAddAxisCellsNames
/// <summary>
/// Returns a name for the CellBoundsVariable * ServiceDimensionForCellBoundsVar
/// </summary>
/// <param name="ds"></param>
/// <param name="name"></param>
/// <param name="boundsVariableName"></param>
/// <returns></returns>
private static Tuple<string, string> EnsureAddAxisCellsNames(DataSet ds, string name, string boundsVariableName)
{
string boundsVarName = boundsVariableName;
if (boundsVarName == null)
{
boundsVarName = string.Format("{0}_bnds", name);
if (ds.Variables.Contains(boundsVarName))
{
int tryNum = 1;
while (ds.Variables.Contains(string.Format("{0}_bnds{1}", boundsVarName, tryNum)))
tryNum++;
boundsVarName = string.Format("{0}_bnds{1}", boundsVarName, tryNum);
}
}
if (ds.Variables.Contains(boundsVarName))
throw new ArgumentException(string.Format("The dataset is already contains a variable with a name {0}. Please specyfy another one or omit it for automatic name choice", boundsVarName));
string sndDim = "nv";
if (ds.Dimensions.Contains(sndDim) && ds.Dimensions[sndDim].Length != 2)
{
int num = 1;
while (ds.Dimensions.Contains(string.Format("{0}{1}", sndDim, num)))
num++;
sndDim = string.Format("{0}{1}", sndDim, num);
}
return Tuple.Create(boundsVarName, sndDim);
}
示例3: GetAllINV_StoresWithRelation
public static DataSet GetAllINV_StoresWithRelation()
{
DataSet iNV_Stores = new DataSet();
SqlINV_StoreProvider sqlINV_StoreProvider = new SqlINV_StoreProvider();
iNV_Stores = sqlINV_StoreProvider.GetAllINV_Stores();
return iNV_Stores;
}
示例4: PublishActivity
public static string PublishActivity(int ClubId, string ActivityContent)
{
// 将新增活动存入数据库,并从数据库返回信息及数据
string connString = System.Configuration.ConfigurationManager.ConnectionStrings["CZConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(connString);
conn.Open();
// 存储
string PublishDate = DateTime.Now.ToString();
string queryString1 = "Insert Into Activity Values (" + ClubId + ",N'" + ActivityContent + "','" + PublishDate + "')";
SqlCommand cmd = new SqlCommand(queryString1, conn);
cmd.ExecuteNonQuery();
// 查询最后插入的数据,就是新的数据
string queryString2 = "Select Top 1 * From Activity Where ClubId=" + ClubId + " Order By PublishDate Desc";
cmd = new SqlCommand(queryString2, conn);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
int Id = Convert.ToInt32(ds.Tables[0].Rows[0]["Id"].ToString());
string Content = ds.Tables[0].Rows[0]["Content"].ToString();
string Date = ds.Tables[0].Rows[0]["PublishDate"].ToString();
conn.Close();
// 通过判断前后时间知是否查入成功
if (PublishDate == Date)
{
return "{status:1,id:" + Id + ",content:'" + Content + "',date:'" + Date + "'}";
}
else
{
return "{status:-1}";
}
}
示例5: GetDropDownListAllHR_WorkingDaysShifting
public static DataSet GetDropDownListAllHR_WorkingDaysShifting()
{
DataSet hR_WorkingDaysShiftings = new DataSet();
SqlHR_WorkingDaysShiftingProvider sqlHR_WorkingDaysShiftingProvider = new SqlHR_WorkingDaysShiftingProvider();
hR_WorkingDaysShiftings = sqlHR_WorkingDaysShiftingProvider.GetDropDownLisAllHR_WorkingDaysShifting();
return hR_WorkingDaysShiftings;
}
示例6: LoadActiveSubMenu
// To get 'SubMenu' record of 'Active' or 'Inactive' from database by stored procedure
public DataTable LoadActiveSubMenu(bool IsActive,int LoggedInUser, string RetMsg)
{
SqlConnection Conn = new SqlConnection(ConnString);
// 'uspGetSubMenuDetails' stored procedure is used to get specific records from SubMenu table
SqlDataAdapter DAdapter = new SqlDataAdapter("uspGetSubMenuDetails", Conn);
DAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet DSet = new DataSet();
try
{
DAdapter.SelectCommand.Parameters.AddWithValue("@IsActive", IsActive);
DAdapter.SelectCommand.Parameters.AddWithValue("@LoggedInUser", LoggedInUser);
DAdapter.SelectCommand.Parameters.AddWithValue("@RetMsg", RetMsg);
DAdapter.Fill(DSet, "Masters.SubMenu");
return DSet.Tables["Masters.SubMenu"];
}
catch
{
throw;
}
finally
{
DSet.Dispose();
DAdapter.Dispose();
Conn.Close();
Conn.Dispose();
}
}
示例7: btnOK_Click
protected void btnOK_Click(object sender, EventArgs e)
{
string ID;
SqlConnection mycon = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
mycon.Open();
DataSet mydataset = new DataSet();
SqlDataAdapter mydataadapter = new SqlDataAdapter("select * from tb_Blog where UserName='" + Session["UserName"] + "'", mycon);
mydataadapter.Fill(mydataset, "tb_Blog");
DataRowView rowview = mydataset.Tables["tb_Blog"].DefaultView[0];
ID = rowview["BlogID"].ToString();
string P_str_Com = "Insert into tb_Message(FriendName,Sex,HomePhone,MobilePhone,QQ,ICQ,Address,Birthday,Email,PostCode,BlogID,IP)"
+" values ('"+this.txtName.Text+"','"+this.DropDownList1.SelectedValue+"','"+this.txtHphone.Text+"'"
+",'"+this.txtMphone.Text+"','"+this.txtQQ.Text+"','"+this.txtICQ.Text+"','"+this.txtAddress.Text+"'"
+",'"+this.txtBirthday.Text+"','"+this.txtEmail.Text+"','"+this.txtPostCode.Text+"','"+ID+"','"+Request.UserHostAddress+"')";
SqlData da = new SqlData();
if (!ValidateDate1(txtBirthday.Text) && !ValidateDate2(txtBirthday.Text) && !ValidateDate3(txtBirthday.Text))
{
Response.Write("<script language=javascript>alert('输入的日期格式有误!');location='javascript:history.go(-1)'</script>");
}
else
{
bool add = da.ExceSQL(P_str_Com);
if (add == true)
{
Response.Write("<script language=javascript>alert('添加成功!');location='AddLinkMan.aspx'</script>");
}
else
{
Response.Write("<script language=javascript>alert('添加失败!');location='javascript:history.go(-1)'</script>");
}
}
}
示例8: getProductById
//---------------------------------
protected internal DataSet getProductById(int id)
{
try
{
Open();
DataSet dataset = new DataSet();
SqlCommand cmd = new SqlCommand();
cmd.Connection = DataBase;
cmd.CommandText = "Get_FeatProduct_By_ID";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@id", SqlDbType.Int);
//Setting values to Parameters.
cmd.Parameters[0].Value = id;
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
adapter.Fill(dataset);
cmd.Dispose();
Close();
return dataset;
}
catch (SqlException oSqlExp)
{
//Console.WriteLine("" + oSqlExp.Message);
return null;
}
catch (Exception oEx)
{
//Console.WriteLine("" + oEx.Message);
return null;
}
}
示例9: GetAllHR_SalaryIncrementsWithRelation
public static DataSet GetAllHR_SalaryIncrementsWithRelation()
{
DataSet hR_SalaryIncrements = new DataSet();
SqlHR_SalaryIncrementProvider sqlHR_SalaryIncrementProvider = new SqlHR_SalaryIncrementProvider();
hR_SalaryIncrements = sqlHR_SalaryIncrementProvider.GetAllHR_SalaryIncrements();
return hR_SalaryIncrements;
}
示例10: GetDropDownListAllSTD_ClassSubjectEmployee
public static DataSet GetDropDownListAllSTD_ClassSubjectEmployee()
{
DataSet sTD_ClassSubjectEmployees = new DataSet();
SqlSTD_ClassSubjectEmployeeProvider sqlSTD_ClassSubjectEmployeeProvider = new SqlSTD_ClassSubjectEmployeeProvider();
sTD_ClassSubjectEmployees = sqlSTD_ClassSubjectEmployeeProvider.GetDropDownListAllSTD_ClassSubjectEmployee();
return sTD_ClassSubjectEmployees;
}
示例11: GetSTD_ClassSubjectByClassSubjectID
public static DataSet GetSTD_ClassSubjectByClassSubjectID(int ClassSubjectID,bool isDataset)
{
DataSet sTD_ClassSubjectEmployee = new DataSet();
SqlSTD_ClassSubjectEmployeeProvider sqlSTD_ClassSubjectEmployeeProvider = new SqlSTD_ClassSubjectEmployeeProvider();
sTD_ClassSubjectEmployee = sqlSTD_ClassSubjectEmployeeProvider.GetSTD_ClassSubjectEmployeeByClassSubjectID(ClassSubjectID,isDataset);
return sTD_ClassSubjectEmployee;
}
示例12: btnsubmit_Click
protected void btnsubmit_Click(object sender, EventArgs e)
{
BALLogin objloginbal = new BALLogin();
DALLogin objlogindal = new DALLogin();
objloginbal.UserName = Session["username"].ToString();
objloginbal.Password = txtoldpassword.Text;
DataSet ds = new DataSet();
ds=objlogindal.ValidateLogin(objloginbal);
if(ds.Tables[0].Rows.Count>0)
{
objloginbal.LoginId = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
objloginbal.Password = txtnewpassword.Text;
objlogindal.ChangePassword(objloginbal);
Response.Write("<script>alert('Password Changed');</script>");
}
else
{
Response.Write("<script>alert('Invalid Login Details');</script>");
}
}
示例13: BindGrandChild
public DataSet BindGrandChild(int nid)
{
SqlDataAdapter da = new SqlDataAdapter("select NEWS_ID, CHANNEL_ID , USERID, TIEUDE, NGAY, STT, CAP_ID from TINTUC01_ENG where MENU_SUB = 1 and NHOM = "+nid+" order by STT", con);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
示例14: BindChild
public DataSet BindChild(int stt)
{
SqlDataAdapter da = new SqlDataAdapter("select NEWS_ID, TIEUDE, USERID, CHANNEL_ID, MENU_SUB, NGAY, STT, CAP_ID from TINTUC01_ENG where MENU_SUB = 0 and CHANNEL_ID = "+stt+" order by STT", con);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
示例15: GetAllLIB_SubCategoriesWithRelation
public static DataSet GetAllLIB_SubCategoriesWithRelation()
{
DataSet lIB_SubCategories = new DataSet();
SqlLIB_SubCategoryProvider sqlLIB_SubCategoryProvider = new SqlLIB_SubCategoryProvider();
lIB_SubCategories = sqlLIB_SubCategoryProvider.GetAllLIB_SubCategories();
return lIB_SubCategories;
}