| | |
datagrid
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2006
Posts: 5
Reputation:
Solved Threads: 0
Hi all
i'm trying to populate a datagrid with a data from a sql database and i keep getting this error The ConnectionString property has not been initialized.
my code looks something like this:
<Private Sub GetAssetDetails()
Dim cnn As New SqlClient.SqlConnection
Dim sql1 As String = "SELECT DETAIL.[OFFICE LOCATION],USERS._RESOURCEGUID,OS.[OS NAME]AS PRODUCTS,PROD.KNOWNAS AS PRODUCTS, USERS.[LAST LOGON]FROM INV_AEX_EU_CONTACT_DETAIL DETAIL,INV_AEX_EU_LOGON_USERS USERS,INV_AEX_SW_MICROSOFT_OFFICE PROD, INV_AEX_OS_OPERATING_SYSTEM(OS)WHERE DETAIL._RESOURCEGUID = USERS._RESOURCEGUID AND USERS._RESOURCEGUID = OS._RESOURCEGUID AND OS._RESOURCEGUID=PROD._RESOURCEGUID"
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql1, cnn)
cnn.Open()
Dim rs As SqlClient.SqlDataReader = command.ExecuteReader
rs = Command.ExecuteReader()
grdDetails.DataSource = rs
grdDetails.DataBind()
cnn.Close()
>
i've tried about everything but i can't seem to get it right.
please help
i'm trying to populate a datagrid with a data from a sql database and i keep getting this error The ConnectionString property has not been initialized.
my code looks something like this:
<Private Sub GetAssetDetails()
Dim cnn As New SqlClient.SqlConnection
Dim sql1 As String = "SELECT DETAIL.[OFFICE LOCATION],USERS._RESOURCEGUID,OS.[OS NAME]AS PRODUCTS,PROD.KNOWNAS AS PRODUCTS, USERS.[LAST LOGON]FROM INV_AEX_EU_CONTACT_DETAIL DETAIL,INV_AEX_EU_LOGON_USERS USERS,INV_AEX_SW_MICROSOFT_OFFICE PROD, INV_AEX_OS_OPERATING_SYSTEM(OS)WHERE DETAIL._RESOURCEGUID = USERS._RESOURCEGUID AND USERS._RESOURCEGUID = OS._RESOURCEGUID AND OS._RESOURCEGUID=PROD._RESOURCEGUID"
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql1, cnn)
cnn.Open()
Dim rs As SqlClient.SqlDataReader = command.ExecuteReader
rs = Command.ExecuteReader()
grdDetails.DataSource = rs
grdDetails.DataBind()
cnn.Close()
>
i've tried about everything but i can't seem to get it right.
please help
•
•
Join Date: May 2006
Posts: 4
Reputation:
Solved Threads: 0
add the folling code: in web.config file
<appSettings>
<addkey="ConnectionString"value="Server=servername;uid=user;pwd=password;Initial Catalog=databasename;Connect Timeout=200"></add>
</appSettings>
<Private Sub GetAssetDetails()
dim myconn AsString = ConfigurationSettings.AppSettings("ConnectionString")
Dim cnn AsSqlClient.SqlConnection
cnn= New SqlConnection(myconn)
then your code..it will work
<appSettings>
<addkey="ConnectionString"value="Server=servername;uid=user;pwd=password;Initial Catalog=databasename;Connect Timeout=200"></add>
</appSettings>
<Private Sub GetAssetDetails()
dim myconn AsString = ConfigurationSettings.AppSettings("ConnectionString")
Dim cnn AsSqlClient.SqlConnection
cnn= New SqlConnection(myconn)
then your code..it will work
•
•
•
•
Originally Posted by katli
Hi all
i'm trying to populate a datagrid with a data from a sql database and i keep getting this error The ConnectionString property has not been initialized.
my code looks something like this:
<Private Sub GetAssetDetails()
Dim cnn As New SqlClient.SqlConnection
Dim sql1 As String = "SELECT DETAIL.[OFFICE LOCATION],USERS._RESOURCEGUID,OS.[OS NAME]AS PRODUCTS,PROD.KNOWNAS AS PRODUCTS, USERS.[LAST LOGON]FROM INV_AEX_EU_CONTACT_DETAIL DETAIL,INV_AEX_EU_LOGON_USERS USERS,INV_AEX_SW_MICROSOFT_OFFICE PROD, INV_AEX_OS_OPERATING_SYSTEM(OS)WHERE DETAIL._RESOURCEGUID = USERS._RESOURCEGUID AND USERS._RESOURCEGUID = OS._RESOURCEGUID AND OS._RESOURCEGUID=PROD._RESOURCEGUID"
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql1, cnn)
cnn.Open()
Dim rs As SqlClient.SqlDataReader = command.ExecuteReader
rs = Command.ExecuteReader()
grdDetails.DataSource = rs
grdDetails.DataBind()
cnn.Close()
>
i've tried about everything but i can't seem to get it right.
please help![]()
•
•
Join Date: May 2006
Posts: 13
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by katli
Hi all
i'm trying to populate a datagrid with a data from a sql database and i keep getting this error The ConnectionString property has not been initialized.
my code looks something like this:
<Private Sub GetAssetDetails()
Dim cnn As New SqlClient.SqlConnection
Dim sql1 As String = "SELECT DETAIL.[OFFICE LOCATION],USERS._RESOURCEGUID,OS.[OS NAME]AS PRODUCTS,PROD.KNOWNAS AS PRODUCTS, USERS.[LAST LOGON]FROM INV_AEX_EU_CONTACT_DETAIL DETAIL,INV_AEX_EU_LOGON_USERS USERS,INV_AEX_SW_MICROSOFT_OFFICE PROD, INV_AEX_OS_OPERATING_SYSTEM(OS)WHERE DETAIL._RESOURCEGUID = USERS._RESOURCEGUID AND USERS._RESOURCEGUID = OS._RESOURCEGUID AND OS._RESOURCEGUID=PROD._RESOURCEGUID"
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql1, cnn)
cnn.Open()
Dim rs As SqlClient.SqlDataReader = command.ExecuteReader
rs = Command.ExecuteReader()
grdDetails.DataSource = rs
grdDetails.DataBind()
cnn.Close()
>
i've tried about everything but i can't seem to get it right.
please help![]()
cnn.connectionString="your sqlConnection" then you
open your connection.
Insha Allah this will Work and if the problem persist then mail me
khanayub_chand@yahoo.com
![]() |
Similar Threads
- binding a datagrid to a datareader (ASP.NET)
- Printing the datagrid control (ASP.NET)
- How to sort the rows in the datagrid and update it successfully? (VB.NET)
- Use of DataGrid (ASP.NET)
- Remove link frame around picture in Datagrid (ASP.NET)
- Linking to E-mail through datagrid (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: using VB2003 to accept excel file and convert it into a graph
- Next Thread: CheckedListBox !!!!
| Thread Tools | Search this Thread |
.net .net2008 30minutes 2005 2008 access account arithmetic array basic bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dropdownlist excel fade file-dialog filter folder ftp generatetags google gridview hardcopy images input insert intel internet mobile monitor ms net networking objects output panel passingparameters peertopeervideostreaming picturebox picturebox1 port position print printing problem problemwithinstallation project save searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer timespan toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year





