⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sp.aspx.cs

📁 数据库连接查询
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -