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

Source: Internet
Author: User
Tags how to use sql
Tips for creating a dynamic MSSQL database table (1): You don't need any other functions to support it. you only need to use some SQL statements provided by MYSQL. For the sake of simplicity, take the MYSQL system table USER as an example to retrieve all possible values in the SELECT_PRIV column. Method: show columns from table_name LIKE enum_column_name the lower-case section needs to be changed according to your situation.


In fact, there is no need for other functions to support it. you only need to use some SQL statements provided by MYSQL.
For the sake of simplicity, take the MYSQL system table USER as an example to retrieve all possible values in the SELECT_PRIV column.

Method: show columns from table_name LIKE enum_column_name

The lower case must be changed according to your situation.

Program:


// By SonyMusic (sonymusic@163.com)
// HomePage (phpcode.yeah.net)
$ Connect_hostname = "localhost ";
$ Dbn The following describes how to use SQL statements to create databases, tables, stored procedures, views, indexes, rules, modify tables, and view data. The following controls are added:
The following is a reference clip:


Imports System. Data
Imports System. Data. SqlClient
Public Class Form1
Inherits System. Windows. Forms. Form
Private ConnectionString As String = "Data Source =.; Initial Catalog =; User Id = sa; Password = ;"
Private reader As SqlDataReader = Nothing
Private conn As SqlConnection = Nothing
Private cmd As SqlCommand = Nothing
Private AlterTableBtn As System. Windows. Forms. Button
Private SQL As String = Nothing
Private CreateOthersBtn As System. Windows. Forms. Button
# Region "code generated by Windows Form Designer"
'Form rewriting disposal to clear the component list.
Protected Overloads Overrides Sub Dispose (ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
Components. Dispose ()
End If
End If
MyBase. Dispose (disposing)
End Sub
Public Sub New ()
MyBase. New ()
InitializeComponent ()
End Sub
Private components As System. ComponentModel. IContainer
Friend WithEvents DataGrid1 As System. Windows. Forms. DataGrid
Friend WithEvents CreateDBBtn As System. Windows. Forms. Button
Friend WithEvents CreateTableBtn As System. Windows. Forms. Button
Friend WithEvents CreateSPBtn As System. Windows. Forms. Button
Friend WithEvents CreateViewBtn As System. Windows. Forms. Button
Friend WithEvents btnAlterTable As System. Windows. Forms. Button
Friend WithEvents btnCreateOthers As System. Windows. Forms. Button
Friend WithEvents btnDropTable As System. Windows. Forms. Button
Friend WithEvents btnViewData As System. Windows. Forms. Button
Friend WithEvents btnViewSP As System. Windows. Forms. Button
Friend WithEvents btnViewView As System. Windows. Forms. Button
Private Sub InitializeComponent ()

Ame = "mysql ";
$ Connect_username = "root ";
$ Connect_pass = "";
$ Connect_id = mysql_connect ($ connect_hostname, $ connect_username, $ connect_pass );
Mysql_select_db ($ dbname );
$ Query = "show columns from user like 'Select _ priv '";
$ Result = mysql_db_query ($ dbname, $ query );
$ Enum = mysql_result ($ result, 0, "type ");
Network management network bitsCN_com
Echo $ enum ."
";
$ Enum_arr = explode ("(", $ enum );
$ Enum = $ enum_arr [1];
$ Enum_arr = explode (")", $ enum );
$ Enum = $ enum_arr [0];
$ Enum_arr = explode (",", $ enum );
For ($ I = 0; $ I
Echo $ enum_arr [$ I]."
";
}
?>

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.