Asp.net连接Sql数据库的语法例子

Dim myConnection As SqlClient.SqlConnection
        Dim myCommand As SqlClient.SqlCommand
        Dim myReader As SqlClient.SqlDataReader
        Dim strSql As String
        Dim ConnStr As String

        strSql = "SELECT P_NAME FROM M_PLOR"
        ConnStr = "server=WHATEVER;packet size=4096;user id=sa;password="sa";data source=ISO2;persist secu" & _
                    "rity info=False;initial catalog=wuye"

        myConnection = New SqlClient.SqlConnection(ConnStr)
        myConnection.Open()
        myCommand = New SqlClient.SqlCommand(strSql, myConnection)

        myReader = myCommand.ExecuteReader

        Dim n As Integer
        n = myReader.FieldCount

        Dim str As String


        ShipMethod.DataSource = myReader
        ShipMethod.DataBind()

你可能感兴趣的:(Asp.net,asp.net,数据库,sql,string,integer,server)