日期:2009-10-11 浏览次数:20465 次
Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=.;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=J;Use Encryption for Data=False;Tag with column collation when possible=False") con.Open() Dim cmd As New OleDb.OleDbCommand("create database jk", con) cmd.ExecuteNonQuery() con.Close() '建立数据库 End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim con2 As New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=jk;Data Source=.;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=J;Use Encryption for Data=False;Tag with column collation when possible=False") con2.Open() Dim cmd As New OleDb.OleDbCommand("create table kk(id int identity(1,1) not null constraint id primary key,name char(4) not null)", con2) cmd.ExecuteNonQuery() Dim cmd2 As New OleDb.OleDbCommand("create table pp(id int not null,ads char(20) null)", con2) cmd2.ExecuteNonQuery() con2.Close() '建立2个表 End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim con2 As New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=jk;Data Source=.;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=J;Use Encryption for Data=False;Tag with column collation when possible=False") con2.Open() Dim com As New OleDb.OleDbCommand("alter table pp add primary key (id)", con2) com.ExecuteNonQuery() con2.Close() '建立约束 End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim con2 As New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=jk;Data Source=.;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=J;Use Encryption for Data=False;Tag with column collation when possible=False") con2.Open() Dim com As New OleDb.OleDbCommand("create proc procname as select * from kk", con2) com.ExecuteNonQuery() con2.Close() '建立存储过程 End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim con2 As New OleDb.OleDbConnection("Provider=
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
|