Datasource - System.Data.DataRowView

torg

Well-known member
Joined
Nov 7, 2002
Messages
60
Location
Norway
When I`m trying to run following code, i receive in listboxAmount the following message: System.Data.DataRowView
Anybody got an Idea why?

Code:
Public Class frmBudget
    Inherits System.Windows.Forms.Form
    Dim OleDbConnection As OleDb.OleDbConnection
.
.
Dim adExpences As OleDb.OleDbDataAdapter
Dim dsExpences As DataSet = New DataSet()


Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myDate As String = dtpDate.Value
        Dim myString As String

        myString = (myDate)
        myString = myString.Replace(".", "/")

        Try
            Me.OleDbConnection.Open()
            dsExpences.Clear()
            adExpences = New OleDb.OleDbDataAdapter("SELECT Sum(tblExpences.Amount) AS Total Expences from tblExpences where tblExpences.date1 = #" & myString & "#;", Me.OleDbConnection)
            adExpences.Fill(dsExpences, "dtExpences")
            llistboxAmount .DataSource = dsExpences.Tables("dtExpences")
            Me.OleDbConnection.Close()
        Catch ex As OleDb.OleDbException
            MessageBox.Show(ex.Message)
        End Try
end sub
 
The connectionstring was set
.
I solved my problem. but I have another problem that I hope someone can help me with.

the format of dtpDate is: DD.MM.YYYY.
the Dato column of tblExpences has the dataType date/time, and
the format is short date. This is an access database

if the date in dtpDato is 19 january 2003, then I want to select all records from tblExpences where the month of tblExpences.Dato is the same as the month of dtpDato. In this example the monthvalue = 1.
How would i do that? I have tried all possible code and combinations I can come up with. I`d appreciate som advices

Code:
Dim myDate As String = dtpDate.Text
        Date.Parse(myDate)
        myDate = myDate.Replace(".", "/") 
        Me.OleDbConnection.Open()
        adExpences = New OleDb.OleDbDataAdapter("SELECT sum(tblExpences.Amount) as Amount from tblExpences where tblExpences.Dato = #" & myDate & "#;", Me.OleDbConnection)
 
Back
Top