| | |
how to use configuration manager in visual studio 2003
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2008
Posts: 4
Reputation:
Solved Threads: 0
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...
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...
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
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
www.houseshark.net
•
•
Join Date: Aug 2008
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
ConfigurationManager did not exist until .net 2.0, use visual studio 2005 to be able to use it.
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
VB.NET Syntax (Toggle Plain Text)
'In Module 'Declare outside of class Imports System.Data Imports System.Data.SqlClient Module Koneksi Public conn As SqlConnection Public Function GetConnect() conn = New SqlConnection("server = MyServerName;database = MyDatabaseName;Trusted_Connection = yes") Return conn End Function End Module
Ex : load data in datagrid
vb.net Syntax (Toggle Plain Text)
'In Form 'Declare outside of class Imports System.Data Imports System.Data.SqlClient 'Procedure To show data in DataGrid Private Sub ShowDataGrid() Dim conn As SqlConnection Dim cmdStudent As New SqlCommand Dim daStudent As New SqlDataAdapter Dim dsStudent As New DataSet Dim dtStudent As New DataTable conn = GetConnect() Try cmdStudent = conn.CreateCommand cmdStudent.CommandText = "SELECT * FROM YourTableName" daStudent.SelectCommand = cmdStudent daStudent.Fill(dsStudent, "YourTableName") dgStudent.DataSource = dsStudent dgStudent.DataMember = "YourTableName" dgStudent.ReadOnly = True Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!") End Try End Sub ' Call procedure ShowDataGrid() on event Form Load Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ShowDataGrid() ' Load data to view in data grid End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
In .net 1.1 you can use the configuration namespace
System.Configuration.AppSettings
but as stated, in .net 2.0 this is deprecated
System.Configuration.AppSettings
but as stated, in .net 2.0 this is deprecated
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Aug 2008
Posts: 4
Reputation:
Solved Threads: 0
Thanx . I will try n then reply again.
with warm regards
Shailesh
with warm regards
Shailesh
•
•
•
•
VB.NET Syntax (Toggle Plain Text)
'In Module 'Declare outside of class Imports System.Data Imports System.Data.SqlClient Module Koneksi Public conn As SqlConnection Public Function GetConnect() conn = New SqlConnection("server = MyServerName;database = MyDatabaseName;Trusted_Connection = yes") Return conn End Function End Module
Ex : load data in datagrid
vb.net Syntax (Toggle Plain Text)
'In Form 'Declare outside of class Imports System.Data Imports System.Data.SqlClient 'Procedure To show data in DataGrid Private Sub ShowDataGrid() Dim conn As SqlConnection Dim cmdStudent As New SqlCommand Dim daStudent As New SqlDataAdapter Dim dsStudent As New DataSet Dim dtStudent As New DataTable conn = GetConnect() Try cmdStudent = conn.CreateCommand cmdStudent.CommandText = "SELECT * FROM YourTableName" daStudent.SelectCommand = cmdStudent daStudent.Fill(dsStudent, "YourTableName") dgStudent.DataSource = dsStudent dgStudent.DataMember = "YourTableName" dgStudent.ReadOnly = True Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!") End Try End Sub ' Call procedure ShowDataGrid() on event Form Load Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ShowDataGrid() ' Load data to view in data grid End Sub
![]() |
Similar Threads
- Spyware Removal Ads (Viruses, Spyware and other Nasties)
- Another explorer.exe thread. (Viruses, Spyware and other Nasties)
- Universal Search Toolbar (Viruses, Spyware and other Nasties)
- WIN98SE protection (Viruses, Spyware and other Nasties)
- Help...symantec keeping sending email (Viruses, Spyware and other Nasties)
- Removal of Home Search Assistent (Viruses, Spyware and other Nasties)
Other Threads in the VB.NET Forum
- Previous Thread: Please Help ,...its urgent
- Next Thread: Running script on background
| Thread Tools | Search this Thread |
"crystal .net .net2008 2008 access add advanced application array assignment basic beginner box browser button buttons center click code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic dosconsolevb.net editvb.net employees excel exists firewall forms html images isnumericfuntioncall listview map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity open pan pdf picturebox picturebox2 port position print printpreview record regex reuse right-to-left save search serial settings socket sorting sqldatbase sqlserver storedprocedure temp textbox timer timespan transparency txttoxmlconverter useraccounts usercontol vb vb.net vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf wrapingcode xml year






