RBX
In the zone
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 -
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
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