how to use configuration manager in visual studio 2003

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 4
Reputation: shailesh_007 is an unknown quantity at this point 
Solved Threads: 0
shailesh_007 shailesh_007 is offline Offline
Newbie Poster

how to use configuration manager in visual studio 2003

 
0
  #1
Aug 27th, 2008
Hi All,
I am new in vb.net. I am using Visual Studio 2003 and sql 2000.
I want to use configuration manager to retrive the connection from app.config

But I am getting error " Name 'ConfigurationManager' is not declared"

the code, I written, is as follows:
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Configuration.ConfigurationSettings
-----------------------------------------------------------------
Namespace PC

Public Class DataEntry
Inherits System.Windows.Forms.Form

Public Shared Function GetConnectionString(ByVal conName As String) As String
Dim strReturn As New String("")
If Not String.IsNullOrEmpty(conName) Then
strReturn = ConfigurationManager.ConnectionString(conName).ConnectionString
Else
strReturn = ConfigurationManager.ConnectionString("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ACCOUNTS;Data Source=winxp").ConnectionString

End If
Return strReturn

End Function

Please help me out...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: how to use configuration manager in visual studio 2003

 
0
  #2
Aug 27th, 2008
ConfigurationManager did not exist until .net 2.0, use visual studio 2005 to be able to use it.
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 4
Reputation: shailesh_007 is an unknown quantity at this point 
Solved Threads: 0
shailesh_007 shailesh_007 is offline Offline
Newbie Poster

Re: how to use configuration manager in visual studio 2003

 
0
  #3
Aug 28th, 2008
Originally Posted by dickersonka View Post
ConfigurationManager did not exist until .net 2.0, use visual studio 2005 to be able to use it.
thanks dear. but can u tell me if i can use other code instead of configurationmanager?
i will be greatful of u if u could provide me alternate code..

And i think bindingsource is also not exist in VS 2003. Pls give me the alternate for binding source also if possible.

with regards

shailesh
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: how to use configuration manager in visual studio 2003

 
0
  #4
Aug 28th, 2008
  1. 'In Module
  2. 'Declare outside of class
  3. Imports System.Data
  4. Imports System.Data.SqlClient
  5.  
  6. Module Koneksi
  7. Public conn As SqlConnection
  8. Public Function GetConnect()
  9. conn = New SqlConnection("server = MyServerName;database = MyDatabaseName;Trusted_Connection = yes")
  10. Return conn
  11. End Function
  12. End Module

Ex : load data in datagrid
  1. 'In Form
  2. 'Declare outside of class
  3. Imports System.Data
  4. Imports System.Data.SqlClient
  5.  
  6. 'Procedure To show data in DataGrid
  7. Private Sub ShowDataGrid()
  8. Dim conn As SqlConnection
  9. Dim cmdStudent As New SqlCommand
  10. Dim daStudent As New SqlDataAdapter
  11. Dim dsStudent As New DataSet
  12. Dim dtStudent As New DataTable
  13.  
  14. conn = GetConnect()
  15. Try
  16. cmdStudent = conn.CreateCommand
  17. cmdStudent.CommandText = "SELECT * FROM YourTableName"
  18. daStudent.SelectCommand = cmdStudent
  19. daStudent.Fill(dsStudent, "YourTableName")
  20. dgStudent.DataSource = dsStudent
  21. dgStudent.DataMember = "YourTableName"
  22. dgStudent.ReadOnly = True
  23. Catch ex As Exception
  24. MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!")
  25. End Try
  26. End Sub
  27.  
  28. ' Call procedure ShowDataGrid() on event Form Load
  29. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  30. ShowDataGrid() ' Load data to view in data grid
  31. End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: how to use configuration manager in visual studio 2003

 
0
  #5
Aug 28th, 2008
In .net 1.1 you can use the configuration namespace

System.Configuration.AppSettings

but as stated, in .net 2.0 this is deprecated
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 4
Reputation: shailesh_007 is an unknown quantity at this point 
Solved Threads: 0
shailesh_007 shailesh_007 is offline Offline
Newbie Poster

Re: how to use configuration manager in visual studio 2003

 
0
  #6
Sep 2nd, 2008
Thanx . I will try n then reply again.

with warm regards

Shailesh

Originally Posted by Jx_Man View Post
  1. 'In Module
  2. 'Declare outside of class
  3. Imports System.Data
  4. Imports System.Data.SqlClient
  5.  
  6. Module Koneksi
  7. Public conn As SqlConnection
  8. Public Function GetConnect()
  9. conn = New SqlConnection("server = MyServerName;database = MyDatabaseName;Trusted_Connection = yes")
  10. Return conn
  11. End Function
  12. End Module

Ex : load data in datagrid
  1. 'In Form
  2. 'Declare outside of class
  3. Imports System.Data
  4. Imports System.Data.SqlClient
  5.  
  6. 'Procedure To show data in DataGrid
  7. Private Sub ShowDataGrid()
  8. Dim conn As SqlConnection
  9. Dim cmdStudent As New SqlCommand
  10. Dim daStudent As New SqlDataAdapter
  11. Dim dsStudent As New DataSet
  12. Dim dtStudent As New DataTable
  13.  
  14. conn = GetConnect()
  15. Try
  16. cmdStudent = conn.CreateCommand
  17. cmdStudent.CommandText = "SELECT * FROM YourTableName"
  18. daStudent.SelectCommand = cmdStudent
  19. daStudent.Fill(dsStudent, "YourTableName")
  20. dgStudent.DataSource = dsStudent
  21. dgStudent.DataMember = "YourTableName"
  22. dgStudent.ReadOnly = True
  23. Catch ex As Exception
  24. MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!")
  25. End Try
  26. End Sub
  27.  
  28. ' Call procedure ShowDataGrid() on event Form Load
  29. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  30. ShowDataGrid() ' Load data to view in data grid
  31. End Sub
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC