How to create a dynamic MSSQL database table (5) _ MySQL

Source: Internet
Author: User
How to create a dynamic MSSQL database table (5) cmd = New SqlCommand (SQL, conn)
Cmd. ExecuteNonQuery ()
SQL = "INSERT INTO myTable (myId, myName, myAddress, myValues)" + _
"VALUES (1003, 'The Wonderful World of the Meng Xianhui ', 'http: // xml.sz.luohuedu.net/', 99 )"
Cmd = New SqlCommand (SQL, conn)
Cmd. ExecuteNonQuery ()
SQL = "INSERT INTO myTable (myId, myName, myAddress, myValues)" + _
"VALUES (1004, '4th of the wonderful world of the Meng Xianhui ', '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
'Create a stored procedure
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
'Create a View
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
'Modify the table
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
'Create a rule and an index
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 <9999"
ExecuteSQLStmt (SQL)
End Sub
'Delete a table
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.