打印本文 打印本文 关闭窗口 关闭窗口
在asp.net中操作sql-server数据库的一些小技巧
作者:武汉SEO闵涛  文章来源:敏韬网  点击数4302  更新时间:2007/11/14 13:06:47  文章录入:mintao  责任编辑:mintao

SqlConnection thisConnection=new SqlConnection

("Data Source=(local);Initial Catalog=Northwind;UID=sa;PWD=");

try

{

thisConnection.Open ();

}

catch(Exception ex)

{

thisConnection.Close ();

}

 

string sql1="select * from employees";

string sql2="select * from Customers";

SqlDataAdapter sda=new SqlDataAdapter(sql1,thisConnection);

DataSet ds= new DataSet();

sda.Fill(ds,"myemployees");

sda.Dispose();

 

SqlDataAdapter sda1=new SqlDataAdapter(sql2,thisConnection);

sda1.Fill(ds,"myCustomers");

sda1.Dispose();

 

string t1=ds.Tables["myemployees"].Rows[0]["Hiredate"].ToString();

string t2=ds.Tables["myCustomers"].Rows[0]["ContactTitle"].ToString();

 

Page.RegisterStartupScript("aa","<script language=javascript>alert(''''t1="+t1+",t2="+t2+"'''');</script>");

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口