本文整理汇总了C#中DataAccess.getDataSet方法的典型用法代码示例。如果您正苦于以下问题:C# DataAccess.getDataSet方法的具体用法?C# DataAccess.getDataSet怎么用?C# DataAccess.getDataSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataAccess
的用法示例。
在下文中一共展示了DataAccess.getDataSet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnEmployee_Click
protected void btnEmployee_Click(object sender, EventArgs e)
{
Response.Write("{\"employees\": [");
string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["OrtegaGoDaddy"].ConnectionString;
DataAccess da = new DataAccess();
System.Data.DataSet ds = da.getDataSet(connectionstring, "select employeeId, employeeFname, employeeLname from Ortega_Employees");
if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
{
Response.Write("{}");
}
else
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Response.Write("{\"employeeid\": \"" +
ds.Tables[0].Rows[i].ItemArray[0].ToString() + "\",\"firstname\":" + "\"" + ds.Tables[0].Rows[i].ItemArray[1].ToString() + "\"}");
if (i < ds.Tables[0].Rows.Count - 1)
{
Response.Write(",");
}
}
}
Response.Write("]}");
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("{\"employees\": [");
string connectionstring =
System.Configuration.ConfigurationManager.ConnectionStrings["HuberGoDaddy"].ConnectionString;
DataAccess da = new DataAccess();
System.Data.DataSet ds = da.getDataSet(connectionstring,
"select employeeid, firstname, lastname from huber_employees");
//if there are no employees returned
if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
{
Response.Write("{}");
}
else
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Response.Write("{\"employeeid\": \"" +
ds.Tables[0].Rows[i].ItemArray[0].ToString() +
"\",\"firstname\":" +
"\"" + ds.Tables[0].Rows[i].ItemArray[1].ToString() + "\"}");
if (i<ds.Tables[0].Rows.Count-1)
{
Response.Write(",");
}
}
}
Response.Write("]}");
}
示例3: btnExample_Click
protected void btnExample_Click(object sender, EventArgs e)
{
Response.Write("{\"employees\": [");
string connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["OrtegaGoDaddy"].ConnectionString;
DataAccess da = new DataAccess();
System.Data.DataSet ds = da.getDataSet(connectionstring, "select employeeid, firstname, lastname from huber_employees");
//System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
//string sql = "select employeeid, firstname, lastname from huber_employees";
//conn.ConnectionString = connectionstring;
//System.Data.DataSet ds = new System.Data.DataSet();
//conn.Open();
//System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(sql, conn);
//System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter();
//da.SelectCommand = comm;
//da.Fill(ds);
//if there are no employees returned
if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
{
Response.Write("{}");
}
else
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Response.Write("{\"employeeid\": \"" +
ds.Tables[0].Rows[i].ItemArray[0].ToString() + "\",\"firstname\":" + "\"" + ds.Tables[0].Rows[i].ItemArray[1].ToString() + "\"}");
if (i < ds.Tables[0].Rows.Count - 1)
{
Response.Write(",");
}
}
}
Response.Write("]}");
}