4. 用DataGrid显示、更新、删除数据库Northwind中Employees表

来源:百度知道 编辑:UC知道 时间:2024/06/04 15:39:21

<%@ 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=Northwind;uid=sa;pwd=" )
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 添加