datagrid

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

Join Date: May 2006
Posts: 5
Reputation: katli is an unknown quantity at this point 
Solved Threads: 0
katli katli is offline Offline
Newbie Poster

datagrid

 
0
  #1
May 22nd, 2006
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
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 4
Reputation: skalyanaraman is an unknown quantity at this point 
Solved Threads: 0
skalyanaraman skalyanaraman is offline Offline
Newbie Poster

Re: datagrid

 
0
  #2
May 23rd, 2006
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

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
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 5
Reputation: katli is an unknown quantity at this point 
Solved Threads: 0
katli katli is offline Offline
Newbie Poster

Re: datagrid

 
0
  #3
May 23rd, 2006
[thanks, i've tried it but get the following error when executing

Parser Error Message: Unrecognized configuration section 'appSettings'

this would be an error from the configuration form
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 4
Reputation: skalyanaraman is an unknown quantity at this point 
Solved Threads: 0
skalyanaraman skalyanaraman is offline Offline
Newbie Poster

Re: datagrid

 
0
  #4
May 23rd, 2006
add that tag inside the tag named <configuration> it will work

Originally Posted by katli
[thanks, i've tried it but get the following error when executing

Parser Error Message: Unrecognized configuration section 'appSettings'

this would be an error from the configuration form
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 13
Reputation: khanayub_chand is an unknown quantity at this point 
Solved Threads: 0
khanayub_chand khanayub_chand is offline Offline
Newbie Poster

Re: datagrid

 
0
  #5
May 24th, 2006
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
Kalti,you have not specified the connection string like
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
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC