PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Connection property has not been initialized

Reply

Connection property has not been initialized

 
Thread Tools Rate Thread
Old 19-09-2006, 07:54 AM   #1
sasi.vempalli@gmail.com
Guest
 
Posts: n/a
Default Connection property has not been initialized


Imports System.Data.sqlclient
Public Class track
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub btntrack_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btntrack.Click
Dim con As New
sqlConnection(ConfigurationSettings.AppSettings("connectionstring"))
Dim tracknumber As Integer
con.Open()
Dim cmd As New sqlCommand
cmd.Connection = con
Response.Redirect("database.aspx")
con.Close()
End Sub
End Class

Actually what i want in this means in first form there is one search
button.When i click that button it goes to the database page and shows
the details of that particular number.In this i put only datagrid.Can u
help me how to collect the data from database?plz.....................



Imports System.Data.sqlclient

Public Class database
Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim con As New
OleDbConnection(ConfigurationSettings.AppSettings("connectionstring"))
Dim TrackNumber As Integer
TrackNumber = CStr(Request.QueryString("TrackNumber"))
Convert.ToString("TrackNumber")
Dim cmd As New OleDbCommand("select * from track where
TrackNumber='" & Request.QueryString("TrackNumber") & " ' ", con)
con.Open()
DataGrid1.DataSource = cmd.ExecuteReader()
DataGrid1.DataBind()
con.Close()
End Sub

End Class

  Reply With Quote
Old 19-09-2006, 03:12 PM   #2
Marina Levit [MVP]
Guest
 
Posts: n/a
Default Re: Connection property has not been initialized

Looks to me like the 'connectionstring' app settings is either not there, or
it is blank. I'm sure you could have figured this out if you had stepped
through the code and looked for its value.

<sasi.vempalli@gmail.com> wrote in message
news:1158648890.004548.251980@m7g2000cwm.googlegroups.com...
> Imports System.Data.sqlclient
> Public Class track
> Inherits System.Web.UI.Page
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> End Sub
>
> Private Sub btntrack_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btntrack.Click
> Dim con As New
> sqlConnection(ConfigurationSettings.AppSettings("connectionstring"))
> Dim tracknumber As Integer
> con.Open()
> Dim cmd As New sqlCommand
> cmd.Connection = con
> Response.Redirect("database.aspx")
> con.Close()
> End Sub
> End Class
>
> Actually what i want in this means in first form there is one search
> button.When i click that button it goes to the database page and shows
> the details of that particular number.In this i put only datagrid.Can u
> help me how to collect the data from database?plz.....................
>
>
>
> Imports System.Data.sqlclient
>
> Public Class database
> Inherits System.Web.UI.Page
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> Dim con As New
> OleDbConnection(ConfigurationSettings.AppSettings("connectionstring"))
> Dim TrackNumber As Integer
> TrackNumber = CStr(Request.QueryString("TrackNumber"))
> Convert.ToString("TrackNumber")
> Dim cmd As New OleDbCommand("select * from track where
> TrackNumber='" & Request.QueryString("TrackNumber") & " ' ", con)
> con.Open()
> DataGrid1.DataSource = cmd.ExecuteReader()
> DataGrid1.DataBind()
> con.Close()
> End Sub
>
> End Class
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off