Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 01-09-2011, 01:33 PM   #1 (permalink)
VIP
 
RazorbladeXtreme's Avatar
 
Join Date: May 2008
Location: Jaipur
Posts: 187
Default VB.net 2008 | ODBC | Move Backwards


We have been told to work on Video Library in DBMS lab using VB and MS Access, however no lessons on how to do it were given. No one knows how to work in VB.

The Database connectivity is quite easy using ADO is VB6 which sadly doesn't work very well in Windows 7 so I'm using VB.net 2008 with ODBC.

Here's the code -

Code:
Imports System.Data.Odbc
Public Class CreateConnection
    Dim con As New OdbcConnection("DSN=VideoLib;")
    Dim cmd As New OdbcCommand
    Public ID As Integer
    Public VidName As String
    Public Price As Integer
    Public odbcReader As OdbcDataReader

    Public Sub New()
        con.Open()
        cmd.Connection = con
        cmd.CommandText = "SELECT * FROM Video"
        odbcReader = cmd.ExecuteReader()
    End Sub

    Public Sub MoveNext()
        If (odbcReader.Read() = True) Then
            ID = odbcReader.GetInt32(0)
            VidName = odbcReader.GetString(1)
            Price = odbcReader.GetInt32(2)
        End If
    End Sub

    Public Sub Creates()
        cmd.CommandText = "INSERT INTO Video(ID,Video_Name,Price) VALUES(" + CType(ID, String) + ",'" + VidName + "'," + CType(Price, String) + ")"
        cmd.ExecuteNonQuery()
    End Sub
End Class
The MoveNext() function works as intended but OdbcDataReader's Read() method moves only forward and I'm unable to move backwards.
Please provide some assistance on this
__________________
Twitter: twitter.com/SharmaTushar
Facebook: facebook.com/tushar.sharma
RazorbladeXtreme is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 01-09-2011, 02:25 PM   #2 (permalink)
Super Moderator
 
asingh's Avatar
 
Join Date: May 2008
Location: New Delhi
Posts: 5,548
Default Re: VB.net 2008 | ODBC | Move Backwards

Why would you want to move back in the recordset.
__________________
MSI P45 Platinum(BIOS v1.7B)|Q9550[E0]@3.85Ghz@1.320V[453x8.5]MCH@1.184V|ICH@1.55V|DDR_V_Ref_A_B@1.05V|NH-D14|Corsair TWIN2X4096-8500C5(5-5-5-15)@1089Mhz@2.14V
2xHD4890[Xfire]@1000/900[MEM/GPU]|Corsair 650TX|Seagate180GB+80GB+WD1TB|SONY-DVD-R|CM690|2x120mm Scythe Ultra Kaze|DELL S2409W|APC 1100VA|Scythe Kaze Server
Windows 7 Ultimate RTM - 64BIT|Catalyst 10.5 (8.14.10.0753) forced with RadeonPRO|PS3 160GB|Sony 40EX520|AC Ryan POHD Mini|APC 800VA|APC 800VA|D425KT|CM100 Elite|2TB WD|Acer D255

Test your spoiler tags before submitting
asingh is online now   Reply With Quote
Old 01-09-2011, 11:37 PM   #3 (permalink)
VIP
 
RazorbladeXtreme's Avatar
 
Join Date: May 2008
Location: Jaipur
Posts: 187
Default Re: VB.net 2008 | ODBC | Move Backwards

That's what my Teacher wants. Textboxes display current record's data and like in ADO, I have to move - Forward, Backward, First, Last.
I could store each record in Arrays and use them for MovePrevious, First, Last etc but that doesn't seem very practical approach considering the space complexity.
__________________
Twitter: twitter.com/SharmaTushar
Facebook: facebook.com/tushar.sharma
RazorbladeXtreme is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:34 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2