だからここに私のコードがあります:
Private adoConnection As System.Data.SqlClient.SqlConnection
Private adoadapterFillDSUsers As New System.Data.SqlClient.SqlDataAdapter()
Private ServerName As String = ""
Private ConnectionString As String = ""
Private Sub adoconn()
adoConnection = New System.Data.SqlClient.SqlConnection()
adoConnection.ConnectionString = DataManager.DataManager.ConnectionString
End Sub
Public Sub ContinueInit()
ReadRegistry()
Dim currRegKey As RegistryKey
Dim newRegKey As RegistryKey
currRegKey = Registry.CurrentConfig
Try
newRegKey = currRegKey.OpenSubKey("Hoh_Dev\Data")
Catch ex As Exception
Return
End Try
Try
MREZA = newRegKey.GetValue("Mreza")
ServerName = newRegKey.GetValue("ServerName")
Catch ex As Exception
Return
End Try
If MREZA = "D" Then
ConnectionString = "Data Source=" & ServerName & ";Integrated Security = SSPI;"
Else
If MREZA = "W" Then
ConnectionString = "Data Source=" & ServerName & ";Database=" & DataBaseName & ";user id=xxx;pwd=xxx;"
End If
End If
adoconn()
End Sub
サーバーに接続してこれを使用するたびに、私はすでに気が狂っています:
If adoConnection.State = ConnectionState.Closed Then adoConnection.Open()
Try
DataManager.DataManager.adoCommand.ExecuteNonQuery()
Catch OpenConnectionError As System.Data.SqlClient.SqlException
End Try
このエラーが発生しました:
The ConnectionString property has not been initialized.
ContinueInit
Form Load Event から subを呼び出します。
Private Sub LogIn_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ContinueInit()
Me.TextBox1.Focus()
Me.TransparencyKey = BackColor
Me.Button2.Visible = False
Me.Button1.Visible = False
TextBox2.PasswordChar = "*"
End Sub
コードがクラックするadoConnection.Open()
と、サーバーへの接続を開くことさえできないため、SQL クエリを実行できます。