3 Replies - 595 Views - Last Post: 01 September 2013 - 05:04 AM Rate Topic: -----

#1 viserys  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-September 13

How do you refer to ALL rows contained within a database?

Posted 01 September 2013 - 12:17 AM

Hi,

I'm using a local database to save check in and check out dates. I then need to check if a certain date is within those dates. It works fine when I start with the program with the database being empty, but if the table already contains dates, I'm unable to refer to those rows.

Error is "There is no row at position 0.", but if i open the table, there is a row at position 0

 Dim all As Integer
 all = Val(formDb.DsRoom.room1.Rows.Count)


   If Not IsDBNull(formDb.DsRoom.room1) Then
            If DateValue(dtpInHome.Text) >= formDb.DsRoom.room1.Rows(all).Item(2) Then
                MsgBox("This date is booked")
            End If
        End If 


Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: How do you refer to ALL rows contained within a database?

#2 viserys  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-September 13

Re: How do you refer to ALL rows contained within a database?

Posted 01 September 2013 - 12:40 AM

Alternate question,

how can I reset the database to containing nothing after I close the program?
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3459
  • View blog
  • Posts: 11,711
  • Joined: 12-December 12

Re: How do you refer to ALL rows contained within a database?

Posted 01 September 2013 - 04:52 AM

I am slightly confused between your first and second posts. Do you need a database at all if you are not storing information permanently?

If you don't need a database then you could create an in-memory New DataTable, among other options. Alternatively, there is an overview here on creating temporary tables in SQL Server (although creating a New DataTable seems more suitable based on your description).

There are also settings for the local database such that it will be created and abandoned on running your application, but this is more suited to a development and debugging process, rather than a permanent feature of an application.

Clarification of your question will help.

This post has been edited by andrewsw: 01 September 2013 - 05:00 AM

Was This Post Helpful? 0
  • +
  • -

#4 viserys  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-September 13

Re: How do you refer to ALL rows contained within a database?

Posted 01 September 2013 - 05:04 AM

Preferably, I'd like it to be able to store information permanently. Although I doubt my teacher will open the program more than once, I'd like to be able to understand database's slightly better for the future.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1