1

vb.net を使用して SQL サーバーに接続しようとしていますが、次のエラーが発生しました。

タイプ 'System.Data.SqlClient.SqlConnection' の値を 'System.Data.SqlClient.SqlConnection の 1 次元配列' に変換できません。

これはタラのソースです:

Imports System.Data.SqlClient

Public Class Form1

    Dim connection As SqlConnection()
    Dim reader As SqlDataReader


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            connection = New SqlConnection("data source=.; initial catalog=tp2_ado; integrated security = sspi")
        Catch ex As Exception
            MessageBox.Show(ex.Message())
        End Try

    End Sub
End Class
4

1 に答える 1

3
Imports System.Data.SqlClient

Public Class Form1

    Dim connection As SqlConnection ' this should not be an array !
    Dim reader As SqlDataReader


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            connection = New SqlConnection("data source=.; initial catalog=tp2_ado; integrated security = sspi")
        Catch ex As Exception
            MessageBox.Show(ex.Message())
        End Try

    End Sub
End Class
于 2013-01-06T17:29:33.060 に答える