PDA Database questions


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: PDA Database questions

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Posts
    32

    Angry PDA Database questions

    I am currently almost complete with a PDA database that i have written in VB 2008.. However 2 problems still persist, i will start with what i think is the easiest to resolve.:
    my database consists of the following columns:

    date

    provider

    charge

    allowed amount

    discount

    applied to deductible

    co-pay

    yearly deductible

    maximum

    other

    payment

    ,,,,,,its a very simple database but remember it is a compact database(it does not have all the functionality of the full blown version) anyway
    what i am attempting to do is read the database with the following sql command:
    Dim cmdPayment As New System.Data.SqlServerCe.SqlCeCommand("SELECT Provider,Date,Payment FROM InsuranceTracker2008 WHERE payment is NOT NULL", conn)


    so what i want to do here is read the database when Payment is NOT NULL then insert the following into a listbox
    date, provider,payment????????? this is where i am stuck
    I do not know how to parse the data and insert into list box?????

    Thanks a bunch
    m2m

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Try
    Code:
    Dim reader As SqlDataReader = cmdPayment.ExecuteReader()
    
            While reader.Read()
                ListBox1.Items.Add(reader.GetString(0) & " " & reader.GetString(1))           
            End While
        End Sub
    The SqlDataReader you use might be something like SqlDataReaderCe.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Dec 2008
    Posts
    32

    Red face Thank You

    I knew there was a good reason why I joined this forum:
    as you mentioned the reader fro the compact database is
    SqlCeDataReader!!
    Any way i get the following erron on this line of code:

    ListBox1.Items.Add(reader.GetString(0) & " " & reader.GetString(1))

    "Invalid cast exception",
    with this stack trace:

    at System.Data.SqlServerCe.SqlCeDataReader.GetString(Int32 ordinal) at Insurance2008.Form1.TabControl1_SelectedIndexChanged(Object sender, EventArgs e) at System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e) at System.Windows.Forms.TabControl.WnProc(WM wm, Int32 wParam, Int32 lParam) at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam) at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain) at System.Windows.Forms.Application.Run(Form fm) at Insurance2008.Form1.Main()


    once again many thanks
    m2m

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote Originally Posted by m2m
    the reader fro the compact database is
    SqlCeDataReader!!
    I was close!
    Quote Originally Posted by m2m
    Any way i get the following erron on this line of code:

    ListBox1.Items.Add(reader.GetString(0) & " " & reader.GetString(1))
    That tells me the item in question is a number, not a string. For strings, use Reader.GetString.

    For numbers use
    Code:
    ListBox1.Items.Add(reader.GetInt32(0).ToString())
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    Dec 2008
    Posts
    32

    Question Error

    Thanks again i get the same error with the following:

    ListBox1.Items.Add(reader.GetString(0) & " " & reader.GetInt32(1).ToString() & " " & reader.GetInt32(2).ToString())

    the first "field" is a string(provider), the second a string(date??) and the third a number(double)

    does that help???

    thanks so much
    m2m

  6. #6
    Join Date
    Sep 2008
    Posts
    86
    Quote Originally Posted by m2m View Post
    Thanks again i get the same error with the following:

    ListBox1.Items.Add(reader.GetString(0) & " " & reader.GetInt32(1).ToString() & " " & reader.GetInt32(2).ToString())

    the first "field" is a string(provider), the second a string(date??) and the third a number(double)

    does that help???

    thanks so much
    m2m
    then your code needs to be...

    Code:
    ListBox1.Items.Add(reader.GetString(0) & " " & reader.GetString(1) & " " & reader.GetDouble(3).ToString);
    you need to match the datatypes of the database fields to the function Get[Datatype]().

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    What did you wind up with?

    It could help someone else.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  8. #8
    Join Date
    Dec 2008
    Posts
    32

    Smile error

    Sure anytime here it is this works fine:

    ListBox1.Items.Add(reader.GetString(0) & "-- " & reader.GetDateTime(1) & "-- " & FormatCurrency(reader.GetSqlMoney(2).ToString()))

  9. #9
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Whoa...GetSqlMoney - I didn't know that one was there.

    I'm glad I asked you to post your solution. I might actually need that one sometime.

    Thanks!
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. multiuser database questions
    By LAByerly in forum VB Classic
    Replies: 1
    Last Post: 02-01-2003, 10:54 AM
  2. Replies: 2
    Last Post: 12-08-2002, 07:20 PM
  3. Really Cool 3 tier Java database solution
    By Russ in forum Database
    Replies: 0
    Last Post: 06-04-2002, 12:57 AM
  4. Database Security General Discussion
    By Michael Tzoanos in forum Database
    Replies: 0
    Last Post: 04-12-2002, 11:19 AM
  5. Multiple Database Architecture
    By mholt28 in forum VB Classic
    Replies: 1
    Last Post: 06-05-2000, 11:21 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center