initialization problem

G

Greg

Hi,

This code gives the error: "The ConnectionString property has not been
initialized" in the line : d.Fill(ds).
The sConnectionString is defined in web.config and refers to a sqlserver mdf
file.

Imports System.Data
Imports System.Data.SqlClient
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

Dim d As SqlDataAdapter
Dim ds As DataSet
Dim sql As String
Dim sConnectionString As String
sConnectionString =
System.Configuration.ConfigurationManager.AppSettings("prod")

sql = "SELECT * FROM [mytable]"
d = New SqlDataAdapter(sql, sConnectionString)
ds = New DataSet()
d.Fill(ds)


Any idea what's wrong? I cant find my error.
Thanks
Greg
 
G

Greg

I found it: the string is wrong:
sConnectionString =
System.Configuration.ConfigurationManager.ConnectionStrings("prod").ToString()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top