problem System.Configuration.ConfigurationManager.ConnectionStrings

  • Thread starter Thread starter Vaidas Gudas
  • Start date Start date
V

Vaidas Gudas

I am getting the error, then I am using
System.Configuration.ConfigurationManager.ConnectionStrings("..."):
'ConfigurationManager' is not a member of 'Configuration'.

in your help it is written that ConfigurationManager is on
System.Configuration class

why.
 
If you're using VS 2005, then you have .NET 2.0. If this is the case, then
you should have the ConfigurationManager available.

Can you provide more of your code?
 
Imports System.Data.SqlClient
Imports System.Configuration
Public Class frmQuestions

Private Sub NaujasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NaujasToolStripMenuItem.Click
Dim Result As DialogResult
frmQuestEdit.veiksmas = 1
Result = frmQuestEdit.ShowDialog(Me)
If Result = Windows.Forms.DialogResult.OK Then

End If
End Sub

Private Sub frmQuestions_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
PopulateTree()
End Sub

Private Sub PopulateTree()
Dim sqlConn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("CallRegistrationConnectionString"))
Dim sqlCmd As SqlClient.SqlCommand
Dim sqlReader As SqlClient.SqlDataReader
sqlConn.Open()
sqlCmd = sqlConn.CreateCommand
sqlCmd.CommandText = "select * from vwKlausimai"
sqlReader = sqlCmd.ExecuteReader
Me.trvwQuestions.Nodes.Clear()
While sqlReader.Read
Debug.Print(sqlReader("Klausimas"))
End While
sqlConn.Close()
End Sub
End Class


in bold section I am geting the error. It is very intrasting that ConfigurationManager working in immediate section.
 
Try removing System.Configuration from the line in question. (Leave just ConfigurationManager.ConnectionStrings(...)).

If that does nothing, try using a string variable to capture the connection string and then use the string as the argument in your SqlConnection.

If these don't work, send back the actual error message you're getting.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."
Imports System.Data.SqlClient
Imports System.Configuration
Public Class frmQuestions

Private Sub NaujasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NaujasToolStripMenuItem.Click
Dim Result As DialogResult
frmQuestEdit.veiksmas = 1
Result = frmQuestEdit.ShowDialog(Me)
If Result = Windows.Forms.DialogResult.OK Then

End If
End Sub

Private Sub frmQuestions_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
PopulateTree()
End Sub

Private Sub PopulateTree()
Dim sqlConn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("CallRegistrationConnectionString"))
Dim sqlCmd As SqlClient.SqlCommand
Dim sqlReader As SqlClient.SqlDataReader
sqlConn.Open()
sqlCmd = sqlConn.CreateCommand
sqlCmd.CommandText = "select * from vwKlausimai"
sqlReader = sqlCmd.ExecuteReader
Me.trvwQuestions.Nodes.Clear()
While sqlReader.Read
Debug.Print(sqlReader("Klausimas"))
End While
sqlConn.Close()
End Sub
End Class


in bold section I am geting the error. It is very intrasting that ConfigurationManager working in immediate section.
 
Back
Top