sp.aspx.cs
来自「数据库连接查询」· CS 代码 · 共 52 行
CS
52 行
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.IO;
public partial class sp : System.Web.UI.Page
{
NorthwindDataContext ctx = new NorthwindDataContext("server=srv-devdbhost;database=Northwind;uid=sa;pwd=Abcd1234");
protected void Page_Load(object sender, EventArgs e)
{
StreamWriter sw = new StreamWriter(Server.MapPath("sp.txt"), false);
ctx.Log = sw;
var 单结果集存储过程 =
from c in ctx.sp_singleresultset()
where c.CustomerID.StartsWith("A")
select c;
int? rowcount = -1;
ctx.sp_withparameter("", ref rowcount);
Response.Write(rowcount);
ctx.sp_withparameter("ALFKI", ref rowcount);
Response.Write(rowcount);
Response.Write(ctx.sp_withreturnvalue(""));
Response.Write(ctx.sp_withreturnvalue("ALFKI"));
//var 多结果集存储过程 = ctx.sp_multiresultset();
//var Customers = 多结果集存储过程.GetResult<Customer>();
//var Employees = 多结果集存储过程.GetResult<Employee>();
//GridView1.DataSource = from emp in Employees where emp.FirstName.Contains("A") select emp;
//GridView1.DataBind();
//GridView2.DataSource = from c in Customers where c.CustomerID.StartsWith("A") select c;
//GridView2.DataBind();
sw.Close();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?