Connection property has not been initialized

S

sasi.vempalli

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
 
M

Marina Levit [MVP]

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.
 

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

Top