教你创建动态MSSQL 数据库表(5)_MySQL
程序员文章站
2024-02-14 11:55:16
...
cmd = New SqlCommand(sql, conn)
cmd.ExecuteNonQuery()
sql = "INSERT INTO myTable(myId, myName, myAddress, myValues) " + _
"VALUES (1003, '【孟宪会之精彩世界】之三', 'http://xml.sz.luohuedu.net/', 99) "
cmd = New SqlCommand(sql, conn)
cmd.ExecuteNonQuery()
sql = "INSERT INTO myTable(myId, myName, myAddress, myValues) " + _
"VALUES (1004, '【孟宪会之精彩世界】之四', 'http://www.erp800.com/net_lover/', 100) "
cmd = New SqlCommand(sql, conn)
cmd.ExecuteNonQuery()
Catch ae As SqlException
MessageBox.Show(ae.Message.ToString())
End Try
End Sub
'创建存储过程
Private Sub CreateSPBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles CreateSPBtn.Click
sql = "CREATE PROCEDURE myProc AS" + " SELECT myName, myAddress FROM myTable GO"
ExecuteSQLStmt(sql)
End Sub
'创建视图
Private Sub CreateViewBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles CreateViewBtn.Click
sql = "CREATE VIEW myView AS SELECT myName FROM myTable"
ExecuteSQLStmt(sql)
End Sub
'修改表
Private Sub btnAlterTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
54com.cn
Handles btnAlterTable.Click
sql = "ALTER TABLE MyTable ADD newCol datetime NOT NULL DEFAULT (getdate())"
ExecuteSQLStmt(sql)
End Sub
'创建规则和索引
Private Sub btnCreateOthers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnCreateOthers.Click
sql = "CREATE UNIQUE INDEX " + "myIdx ON myTable(myName)"
ExecuteSQLStmt(sql)
sql = "CREATE RULE myRule " + "AS @myValues >= 90 AND @myValues ExecuteSQLStmt(sql)
End Sub
'删除表
Private Sub btnDropTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnDropTable.Click
Dim sql As String = "DROP TABLE MyTable"
ExecuteSQLStmt(sql)
End Sub
cmd.ExecuteNonQuery()
sql = "INSERT INTO myTable(myId, myName, myAddress, myValues) " + _
"VALUES (1003, '【孟宪会之精彩世界】之三', 'http://xml.sz.luohuedu.net/', 99) "
cmd = New SqlCommand(sql, conn)
cmd.ExecuteNonQuery()
sql = "INSERT INTO myTable(myId, myName, myAddress, myValues) " + _
"VALUES (1004, '【孟宪会之精彩世界】之四', 'http://www.erp800.com/net_lover/', 100) "
cmd = New SqlCommand(sql, conn)
cmd.ExecuteNonQuery()
Catch ae As SqlException
MessageBox.Show(ae.Message.ToString())
End Try
End Sub
'创建存储过程
Private Sub CreateSPBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles CreateSPBtn.Click
sql = "CREATE PROCEDURE myProc AS" + " SELECT myName, myAddress FROM myTable GO"
ExecuteSQLStmt(sql)
End Sub
'创建视图
Private Sub CreateViewBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles CreateViewBtn.Click
sql = "CREATE VIEW myView AS SELECT myName FROM myTable"
ExecuteSQLStmt(sql)
End Sub
'修改表
Private Sub btnAlterTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
54com.cn
Handles btnAlterTable.Click
sql = "ALTER TABLE MyTable ADD newCol datetime NOT NULL DEFAULT (getdate())"
ExecuteSQLStmt(sql)
End Sub
'创建规则和索引
Private Sub btnCreateOthers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnCreateOthers.Click
sql = "CREATE UNIQUE INDEX " + "myIdx ON myTable(myName)"
ExecuteSQLStmt(sql)
sql = "CREATE RULE myRule " + "AS @myValues >= 90 AND @myValues ExecuteSQLStmt(sql)
End Sub
'删除表
Private Sub btnDropTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnDropTable.Click
Dim sql As String = "DROP TABLE MyTable"
ExecuteSQLStmt(sql)
End Sub
上一篇: 筹建Eclipse PHP开发环境
下一篇: 生手搭建ThinkPHP框架