| I am trying to pull data from the database using simple details view and oledb access database. If Not IsPostBack Then Try ReturnDataset( Dim ds As New DataSet"Select * from ProjectDetails", "mytbl")If Not ds Is Nothing Then DetailsView1.DataSourceID = Nothing DetailsView1.DataSource = ds DetailsView1.DataBind() End If Catch ex As ExceptionEnd Try End If I keep getting this annoying exception and nothing seems to resolve my problem. Please help:-( |
Loading
DOTNET DeveloperPosted Mar 14, 2012, 2:37 PM
Actually I resolved it but I am still trying to figure out what was the cause.
I just created a new aspx page from scratch and re-did my whole code again. I am using oledb connection.
It just worked.
All I can think of i did different was that in my last page i used Control to bind to the source first to get exact connection string. Then I deleted the control and re-did the connection using code behind. May be that cutting and pasting messed up something. I hope I could find what it was..But thankfully its resolved.
Thanks for ur quick response.
Satyapriya NayakPosted Mar 14, 2012, 1:41 PM
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="Detailsview._Default" %>
Imports System.Data
Imports System.Data.SqlClient
Partial Public Class _Default
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim con As New SqlConnection(strConnString)
Dim str As String
Dim com As SqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
bind()
End If
End Sub
Sub bind()
con.Open()
str = "select * from employee"
com = New SqlCommand(str, con)
sqlda = New SqlDataAdapter(com)
ds = New DataSet
sqlda.Fill(ds, "employee")
de1.DataSource = ds
de1.DataMember = "employee"
de1.DataBind()
con.Close()
End Sub
End Class
Thanks