国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

asp.net如何連接sql server2000數(shù)據(jù)庫(kù)

2019-11-18 16:28:32
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

asp.net如何連接SQL Server2000數(shù)據(jù)庫(kù)
 
大家好,以下是有關(guān)ASP.net連接SQL Server2000數(shù)據(jù)庫(kù)的例程,
在這里和大家分享一下:

Asp.net連接SQL Server2000數(shù)據(jù)庫(kù)例程詳解:
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient" %>
<script laguage="VB" runat="server">
sub page_load(sender as Object,e as EventArgs)
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim ds as DataSet
'1.connect to sql server
myConnection = New SqlConnection( "server=localhost;database=Pubs;uid=ueytjdf;pwd=doekdf" )
myConnection.Open()
la1.text="Connection Opened!"
 
'2.Create a table
myCommand = New SqlCommand( "CREATE TABLE [test] ([id] [int] IDENTITY (1, 1) NOT NULL ,[name]
 
[char] (10) COLLATE Chinese_PRC_CI_AS NULL ,[sex] [char] (10) COLLATE Chinese_PRC_CI_AS NULL
 
)", myConnection )
myCommand.ExecuteNonQuery()
la2.text="New table created!"
 
'2 添加紀(jì)錄
myCommand = New SqlCommand( "Insert into [test] (name,sex) values( '黃志文','男' )",
 
myConnection )
myCommand.ExecuteNonQuery()
la3.text="New Record Inserted!"
 
'3 更新數(shù)據(jù)
myCommand = New SqlCommand( "UPDATE [test] SET name='Smith' where name='李明'", myConnection )
myCommand.ExecuteNonQuery()
la4.text="Record Updated!"
 
'4 刪除數(shù)據(jù)
myCommand = New SqlCommand( "delete from [test] where name='Smith'", myConnection )
myCommand.ExecuteNonQuery()
la5.text="Record Deleted!"
 
'5 用DataGrid顯示數(shù)據(jù)
myCommand = New SqlCommand( "select * from [test]", myConnection )
MyDataGrid.DataSource=myCommand.ExecuteReader()
MyDataGrid.DataBind()
end sub
</script>
<html>
<body>
<asp:label id="la1" runat="server" /><br>
<asp:label id="la2" runat="server" /><br>
<asp:label id="la3" runat="server" /><br>
<asp:label id="la4" runat="server" /><br>
<asp:label id="la5" runat="server" /><br>
<ASP:DataGrid id="MyDataGrid" runat="server"
BorderColor="black"
BorderWidth="1"
GridLines="Both"
CellPadding="3"
CellSpacing="0"
Font-Name="Verdana"
Font-Size="10pt"
HeaderStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="#eeeeee"
>
</asp:DataGrid>
 
</body>
</html>


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临颍县| 二连浩特市| 永胜县| 连山| 德州市| 河间市| 阿拉善左旗| 桃园县| 余庆县| 竹山县| 松原市| 萍乡市| 策勒县| 谢通门县| 乳源| 常德市| 长沙市| 河曲县| 镇康县| 阜新市| 青川县| 邢台市| 南召县| 溆浦县| 富川| 榆树市| 平远县| 行唐县| 淳化县| 阿合奇县| 东城区| 博客| 城固县| 松溪县| 甘孜| 黄浦区| 临澧县| 汤阴县| 邛崃市| 乐山市| 镇平县|