954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

datagrid

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:


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:confused:

katli
Newbie Poster
5 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

add the folling code: in web.config file

dim myconn AsString = ConfigurationSettings.AppSettings("ConnectionString")
Dim cnn AsSqlClient.SqlConnection
cnn= New SqlConnection(myconn)

then your code..it will work

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:


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:confused:

skalyanaraman
Newbie Poster
4 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

[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

katli
Newbie Poster
5 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

add that tag inside the tag named it will work

[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

skalyanaraman
Newbie Poster
4 posts since May 2006
Reputation Points: 10
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: 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:confused:



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
[EMAIL="khanayub_chand@yahoo.com"]khanayub_chand@yahoo.com[/EMAIL]

khanayub_chand
Newbie Poster
13 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You