ok i understand some basics of vb but am still relatively a new...

my problem.. code is for saving values into a database and displaying on the same form on a datagrid which is connected to the database...

Imports System.Data.OleDb
Public Class Addbooking
    Inherits System.Windows.Forms.Form

    Public cN As OleDbConnection
    Public myOleDbCommand As OleDbCommand
    Dim Da As New OleDbDataAdapter()
    Dim dataS As New DataSet()
    Dim Nextb As Long
    Dim PrevB As Long
    Dim TotalC As Long


    Private Sub Addbooking_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'LVuserdbDataSet1.Bookings' table. You can move, or remove it, as needed.
        Me.BookingsTableAdapter.Fill(Me.LVuserdbDataSet1.Bookings)

    End Sub

    Private Sub connecttome()
        Nextb = 0
        PrevB = 0
        Dim STrPath = System.IO.Directory.GetCurrentDirectory & "\mydb.mdb"

        Try
            cN = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & STrPath & "';Jet OLEDB:Database Password=1")
            myOleDbCommand = New OleDbCommand("Select * from bookings where StaffID<>null order by name asc")

            cN.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "")
            End
        End Try
        myOleDbCommand.Connection = cN

        Da = New OleDb.OleDbDataAdapter("Select * from bookings where StaffID<>null order by name asc", cN)
        dataS = New DataSet("MS")
        Da.Fill(dataS, "MS")
        DataGridView1.DataSource = dataS
        DataGridView1.DataMember = "MS"

        Dim x = dataS.Tables("ms").Rows.Count()


        TotalC = x - 1



        FILL(0)

        Dim Dr As OleDb.OleDbDataReader = myOleDbCommand.ExecuteReader
        cN.Close()
        Button11()
    End Sub

    Private Sub FILL(ByVal X As Long)
        If dataS Is Nothing Then Return
        Try
            With dataS.Tables("ms").Rows(X)
                stafid.Text = IIf(IsDBNull(.Item("Staff ID")), "NULL", .Item("Staff ID"))
                rooid.Text = IIf(IsDBNull(.Item("Room ID")), "NULL", .Item("Room ID"))
                date1.Text = IIf(IsDBNull(.Item("Date Required")), "NULL", .Item("Date Required"))
                time1.Text = IIf(IsDBNull(.Item("Time Required")), "NULL", .Item("Time Required"))
                areq.Text = IIf(IsDBNull(.Item("Additional requirements")), "NULL", .Item("Additional requirements"))
            End With
        Catch err As Exception

        End Try
        Me.Text = X

    End Sub

    Private Sub Button11()
        btnaddbook.Enabled = True
        If TotalC <= 0 Then
            btnaddbook.Enabled = True
        Else
            btnaddbook.Enabled = False
        End If
    End Sub

    Private Sub btnaddbook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddbook.Click

        If rooid.Text = "" Then
            MsgBox("Invalid StaffID!", MsgBoxStyle.Information, "")
            rooid.Focus()
            Exit Sub
        End If
        If date1.Text = "" Then date1.Text = " "
        If time1.Text = "" Then time1.Text = " "


        If stafid.Text = "" Then
            SAVE()
        Else
            UPDATE1()
        End If


    End Sub

    Private Sub UPDATE1()

        cN.Open()
        Dim SAZ As String
        SAZ = "Update booking set StaffID='" & rooid.Text & "', name='" & date1.Text & "', " _
            & "address='" & time1.Text & "' where StaffID='" & stafid.Text & "'"
        'MsgBox(SQL)
        Dim nwol As New OleDbCommand(SAZ, cN)
        nwol.ExecuteNonQuery()
        cN.Close()
        connecttome()
    End Sub

    Private Sub SAVE()

        Dim DC1 As New OleDb.OleDbCommand()

        Dim SQL As String

        cN.Open()
        'Stop
        Dim Ad As New OleDbDataAdapter("select * from bookings where StaffID='" & rooid.Text & "'", cN)
        Dim Check_dataset As DataSet
        Check_dataset = New DataSet("check")
        Ad.Fill(Check_dataset, "check")
        If Check_dataset.Tables("check").Rows.Count <> 0 Then
            MsgBox("Item StaffID already exists!", MsgBoxStyle.Information, "")
            rooid.SelectionStart = 0
            rooid.SelectionLength = Len(rooid.Text)
            rooid.Focus()
            cN.Close()
            Exit Sub
        End If


        SQL = "Insert into Bookings(StaffID,RoomID,Date required,Time required,Additional requirements) values(" _
            & "'" & stafid.Text & "', " _
            & "'" & rooid.Text & "', " _
            & "'" & date1.Text & "', " _
            & "'" & time1.Text & "', " _
            & "'" & areq.Text & "')"

        'MsgBox(SQL)

        'SQL = "Insert into booking(name) values('x')"
        DC1 = New OleDbCommand(SQL, cN)
        DC1.ExecuteNonQuery()
        '        MsgBox("Save", MsgBoxStyle.OKOnly, "")

        cN.Close()
        connecttome()
    End Sub

End Class

its runs fine until this bit where the error occurs..

Private Sub UPDATE1()

        cN.Open()
        Dim SAZ As String
        SAZ = "Update booking set StaffID='" & rooid.Text & "', name='" & date1.Text & "', " _
            & "address='" & time1.Text & "' where StaffID='" & stafid.Text & "'"
        'MsgBox(SQL)
        Dim nwol As New OleDbCommand(SAZ, cN)
        nwol.ExecuteNonQuery()
        cN.Close()
        connecttome()
    End Sub

Object reference not set to an instance of an object. at cn.open bit... from what i can see my connection seem fine :S and i cant see the problem

Note: this code isnt inch perfect i was jus hopin to display any data on the datagrid for a start...

Can anyone suffice the problem?

help need urgentlyyyy
Many thanks

can you specify what LINE gives you that exception?

the cn.open in the UPDATE bit

sorted

can anyone see the error in this syntax?

Dim SAZ As String
        SAZ = "Update Bookings RoomID='" & rooid.Text & "', Date required='" & date1.Text & "', " _
            & "'Time required='" & time1.Text & "' StaffID='" & stafid.Text & "'"

anynonee helpp with my syntax error??

at the moment its looking like this

SAZ = "Update Bookings set RoomID= '" & rooid.Text & "', [Date required] '" & date1.Text & "', " _
            & "[Time required] '" & time1.Text & "', StaffID '" & stafid.Text & "'"

solved thatt problem... now i have a problem at

Da = New OleDb.OleDbDataAdapter("Select * from bookings where StaffID<>null order by name asc", cN)
        dataS = New DataSet("MS")
       [B] Da.Fill(dataS, "MS")[/B]
        DataGridView1.DataSource = dataS
        DataGridView1.DataMember = "MS"

No value given for one or more required parameters
anyone hazard a guess why?

anynonee helpp with my syntax error??

at the moment its looking like this

SAZ = "Update Bookings set RoomID= '" & rooid.Text & "', [Date required] '" & date1.Text & "', " _
        & "[Time required] '" & time1.Text & "', StaffID '" & stafid.Text & "'"

end quote.

is should look like this:

SAZ = "Update Bookings set Bookings.RoomID= '" & rooid.Text & "', Bookings.Daterequired = '" & Format(date1.Text, "General Date") & "', " _
        & "Bookings.Timerequired = '" & time1.Text & "',Bookings.StaffID = '" & stafid.Text & "' WHERE Bookings.FileID = '" & your strings here &"'"

Do not try to put spaces in your datafield and your query must specify what row to update that is why i supplied the WHERE clause in your statement.

If your Timerequired is a Date/Time Field, you must supply it with the correct Date/Time format in your time1.text, else it will give you another headache.

Tip: you can just have one field for your Daterequired and Timerequired. let say BookingDate so that you will only have one Textbox that will provide the Date and Time of Booking i.e (April 21, 2009 8:00AM)

Just supply the correct parameters and it will solve your problem.

solved thatt problem... now i have a problem at

Da = New OleDb.OleDbDataAdapter("Select * from bookings where StaffID<>null order by name asc", cN)
        dataS = New DataSet("MS")
       [B] Da.Fill(dataS, "MS")[/B]
        DataGridView1.DataSource = dataS
        DataGridView1.DataMember = "MS"

No value given for one or more required parameters
anyone hazard a guess why?

Try this:

Da = New OleDb.OleDbDataAdapter("Select * from bookings where StaffID  is not null order by name asc", cN)
        dataS = New DataSet("MS")
       [B] Da.Fill(dataS, "MS")[/B]
        DataGridView1.DataSource = dataS
        DataGridView1.DataMember = "MS"

i still get the same error?

anyonee?

Try this:

Da = New OleDb.OleDbDataAdapter("Select * from bookings where StaffID  is not null order by name asc", cN)
        dataS = New DataSet("MS")
       [B] Da.Fill(dataS, "MS")[/B]
        DataGridView1.DataSource = dataS
        DataGridView1.DataMember = "MS"

this code is tested by me and it works fine. pls check your parameters:
1. bookings "Table Name"
2. StaffID "Primary Key"
2. name "Table Field"

or maybe your connection to the database is close.

ok checkd the field and what you mentioned... now when i click the button nothing happens :| and data still isnt adding to the database

here is a copy of my up-to-date code :

Imports System.Data.OleDb
Public Class Addbooking
    Inherits System.Windows.Forms.Form

    Public cN As OleDbConnection
    Public myOleDbCommand As OleDbCommand
    Dim Da As New OleDbDataAdapter()
    Dim dataS As New DataSet()
    Dim Nextb As Long
    Dim PrevB As Long
    Dim TotalC As Long
    Dim ConnectString As String = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\LVuserdb.accdb;Jet OLEDB:Database Password=1")


    Private Sub Addbooking_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'LVuserdbDataSet1.Bookings' table. You can move, or remove it, as needed.
        Me.BookingsTableAdapter.Fill(Me.LVuserdbDataSet1.Bookings)
    End Sub
    Private Sub connecttome()
        Nextb = 0
        PrevB = 0
        Dim STrPath = System.IO.Directory.GetCurrentDirectory & "\mydb.mdb"

        Try
            cN = New OleDbConnection(ConnectString)
            myOleDbCommand = New OleDbCommand("Select * from bookings where StaffID<>null order by StaffID asc")

            cN.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "")
            End
        End Try
        myOleDbCommand.Connection = cN

        Da = New OleDbDataAdapter("Select * from Bookings where StaffID<>null order by StaffID asc", cN)
        dataS = New DataSet("MS")
        Da.Fill(dataS, "MS")
        DataGridView1.DataSource = dataS
        DataGridView1.DataMember = "MS"

        Dim x = dataS.Tables("ms").Rows.Count()


        TotalC = x - 1



        FILL(0)

        Dim Dr As OleDb.OleDbDataReader = myOleDbCommand.ExecuteReader
        cN.Close()
        Button11()
    End Sub

    Private Sub FILL(ByVal X As Long)
        If dataS Is Nothing Then Return
        Try
            With dataS.Tables("ms").Rows(X)
                stafid.Text = IIf(IsDBNull(.Item("Staff ID")), "NULL", .Item("Staff ID"))
                rooid.Text = IIf(IsDBNull(.Item("Room ID")), "NULL", .Item("Room ID"))
                date1.Text = IIf(IsDBNull(.Item("Date Required")), "NULL", .Item("Date Required"))
                time1.Text = IIf(IsDBNull(.Item("Time Required")), "NULL", .Item("Time Required"))
                areq.Text = IIf(IsDBNull(.Item("Additional requirements")), "NULL", .Item("Additional requirements"))
            End With
        Catch err As Exception

        End Try
        Me.Text = X

    End Sub

    Private Sub Button11()
        btnaddbook.Enabled = True
        If TotalC <= 0 Then
            btnaddbook.Enabled = True
        Else
            btnaddbook.Enabled = False
        End If
    End Sub

    Private Sub btnaddbook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddbook.Click

        If stafid.Text = "" Then
            MsgBox("Invalid StaffID!", MsgBoxStyle.Information, "")
            rooid.Focus()
            Exit Sub
        End If
        If date1.Text = "" Then date1.Text = " "
        If time1.Text = "" Then time1.Text = " "


        If rooid.Text = "" Then
            SAVE()
        Else
            UPDATE1()
        End If


    End Sub

    Private Sub UPDATE1()

        Dim cn As New OleDbConnection(ConnectString)
        cN.Open()
        Dim SAZ As String
        SAZ = "Update Bookings set StaffID='" & stafid.Text & "', RoomID='" & rooid.Text & "', " _
            & "[Date required]='" & date1.Text & "' where [Time required]='" & time1.Text & "'"
        'MsgBox(SQL)
        Dim nwol As New OleDbCommand(SAZ, cn)
        nwol.ExecuteNonQuery()
        cN.Close()
        connecttome()
    End Sub

    Private Sub SAVE()

        Dim DC1 As New OleDb.OleDbCommand()

        Dim SQL As String

        cN.Open()
        'Stop
        Dim Ad As New OleDbDataAdapter("select * from bookings where StaffID='" & stafid.Text & "'", cN)
        Dim Check_dataset As DataSet
        Check_dataset = New DataSet("check")
        Ad.Fill(Check_dataset, "check")
        If Check_dataset.Tables("check").Rows.Count <> 0 Then
            MsgBox("Item StaffID already exists!", MsgBoxStyle.Information, "")
            rooid.SelectionStart = 0
            rooid.SelectionLength = Len(stafid.Text)
            rooid.Focus()
            cN.Close()
            Exit Sub
        End If


        SQL = "Insert into Bookings(StaffID,RoomID,Date required,Time required,Additional requirements) values(" _
            & "'" & stafid.Text & "', " _
            & "'" & rooid.Text & "', " _
            & "'" & date1.Text & "', " _
            & "'" & time1.Text & "', " _
            & "'" & areq.Text & "')"

        'MsgBox(SQL)

        'SQL = "Insert into booking(name) values('x')"
        DC1 = New OleDbCommand(SQL, cN)
        DC1.ExecuteNonQuery()
        '        MsgBox("Save", MsgBoxStyle.OKOnly, "")

        cN.Close()
        connecttome()
    End Sub

End Class

can anyone see the problem?

i realllllly need to solve this problem urgentlyy if anyone can helpp i'd much appreciate... maybe explaining a few things may make it easier...
so basically:

User enters the data in the fields on the form

stafid.Text & "', " _
            & "'" & rooid.Text & "', " _
            & "'" & date1.Text & "', " _
            & "'" & time1.Text & "', " _
            & "'" & areq.Text

btnaddbook_Click

when user click this, these fields are inputted in the actual Microsoft Access Database which i have already established a connection for...

This inputted data is also displayed on the datagrid on the form so the user can see which bookings have been made... (the update bit at the moment is not that much relevant as that willl be done in a different form)

Private Sub Addbooking_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'LVuserdbDataSet1.Bookings' table. You can move, or remove it, as needed.
        Me.BookingsTableAdapter.Fill(Me.LVuserdbDataSet1.Bookings)
    End Sub


    Private Sub connecttome()
        Nextb = 0
        PrevB = 0
        Dim STrPath = System.IO.Directory.GetCurrentDirectory & "\mydb.mdb"

        Try
            cN = New OleDbConnection(ConnectString)
            myOleDbCommand = New OleDbCommand("Select * from bookings where StaffID<>null order by StaffID asc")

            cN.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "")
            End
        End Try
        myOleDbCommand.Connection = cN

        Da = New OleDbDataAdapter("Select * from Bookings where StaffID<>null order by StaffID asc", cN)
        dataS = New DataSet("MS")
        Da.Fill(dataS, "MS")
        DataGridView1.DataSource = dataS
        DataGridView1.DataMember = "MS"

        Dim x = dataS.Tables("ms").Rows.Count()


        TotalC = x - 1



        FILL(0)

        Dim Dr As OleDb.OleDbDataReader = myOleDbCommand.ExecuteReader
        cN.Close()
        Button11()
    End Sub

What part of your application did you call "Private Sub connecttome()"?

This SQL statement will not return anything (Da = New OleDbDataAdapter("Select * from Bookings where StaffID<>null order by StaffID asc", cN) )

It should be ( Da = New OleDbDataAdapter("Select * from Bookings where StaffID is not null order by StaffID asc", cN))

its not any part of the application it functions itself on the form...

its not any part of the application it functions itself on the form...

yeah, but it will not FUNCTION unless you call it in one of the forms event, like Form_Load or Button_Click ect... If you place that sub in the Module and make it Public, well, it will function.

ok fair enough, the code i got at the moment does pretty much does nothing, except when i enter details in the form and pres add booking , the form name changes to 0....

I have some dejá vu feeling I've posted to this thread.

See The connection string reference for Access connection string(s). You're connection string seems 'suspicios' and it doesn't point to any mdb file? IMO it should be something like "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:Database Password=MyDbPassword;" or "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;" without a password. Just change the datasource to point to your mdb file.

After cN.Open() add a test

If cN.State <> ConnectionState.Open Then
  MessageBox.Show("Couldn't establish the DB connection", "No Connection", MessageBoxButtons.OK, MessageBoxIcon.Warning)
  ' Do some exit
End If

Finally, change the select statement "Select * from bookings where StaffID<>null order by StaffID asc" to "Select * from bookings where StaffID IS NOT NULL order by StaffID asc" just in case (it's more ANSI compliant syntax for testing NULL value).

Didn't read all the thread but I hope there's something new, c0deFr3aK already pointed out that NULL value testing.... :-/

Hi, thanks 4 the replies ... sitll cant manage to figure that problem outt i will run through the code againn mmm...

so i tried a different method with a listbox displaying the data instead... all the code is fine except one error...

Imports System.Data.OleDb
Public Class Addbooking
    Inherits System.Windows.Forms.Form

  
    Dim ConnectString As String = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\LVuserdb.accdb;Jet OLEDB:Database Password=1")


    Private Sub Addbooking_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'LVuserdbDataSet1.Bookings' table. You can move, or remove it, as needed.
        Me.BookingsTableAdapter.Fill(Me.LVuserdbDataSet1.Bookings)
    End Sub

    'Global Declaration for Class frmSM
    Dim AddMode As Boolean
    Dim Ctrl As Integer
    Dim myConn As New OleDbConnection
    Dim myCmd As New OleDbCommand
    Dim myDA As New OleDbDataAdapter
    Dim myDR As OleDbDataReader
    Dim strSQL As String


    Function IsConnected() As Boolean
        Try
            'Checks first if already connected to database,if connected, it will be disconnected.
            If myConn.State = ConnectionState.Open Then myConn.Close()
            myConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\LVuserdb.accdb;Jet OLEDB:Database Password=1"
            myConn.Open()
            IsConnected = True
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Function

    Sub SaveEntry(ByVal StaffID As String, ByVal RoomID As String, ByVal [Date_required] As String, ByVal [Time_required] As String, ByVal [Additional_requirements] As String)
        Try
            If IsExists() = False Then
                'Adds new record to the table
                strSQL = "INSERT INTO Bookings(StaffID,RoomID,[Date required],[Time required],[Additional requirements]) VALUES('" _
                & StaffID.ToUpper & "' ,'" _
                & RoomID.ToUpper & "' ,'" _
                & [Date_required].ToUpper & "' ,'" _
                & [Time_required].ToUpper & "' ,'" _
                & [Additional_requirements].ToUpper & "')"
            Else
                'Updates record from the table
                strSQL = "UPDATE Bookings SET StaffID = '" & StaffID.ToUpper & "'," _
                    & "RoomID = '" & RoomID.ToUpper & "'," _
                    & "[Date required] = '" & [Date_required].ToUpper & "', " _
                    & "[Time required] = '" & [Time_required].ToUpper & "' " _
                    & "[Additional requirements] = '" & [Additional_requirements].ToUpper & "' " _
                    & "WHERE SM_Ctrl = " & Ctrl & ""
            End If
            Dim myCmd As New OleDb.OleDbCommand
            myCmd.CommandText = strSQL
            myCmd.Connection = myConn
            myCmd.ExecuteNonQuery()
            Locked(True)
        Catch ex As Exception
            MsgBox(ex.Message, , "Save Entry")
        End Try
    End Sub

    Function IsExists() As Boolean
        'SearchSM(Ctrl)
        If myDR.HasRows = True Then
            Return True
        Else
            Return False
        End If
    End Function

    Sub Locked(ByVal Mode As Boolean)
        For Each Ctrl As Control In Me.Controls
            If TypeOf Ctrl Is TextBox Then
                Ctrl.Enabled = Not Mode
                Ctrl.Text = ""
                If Ctrl.Name = "StafID" Then
                    Ctrl.Focus()
                End If
            ElseIf TypeOf Ctrl Is Button Then
                If Ctrl.Name = "btnSave" And Ctrl.Enabled = Mode Then
                    Ctrl.Enabled = Not Mode
                ElseIf Ctrl.Name = "btnCancel" And Ctrl.Enabled = Mode Then
                    Ctrl.Enabled = Not Mode
                ElseIf Ctrl.Name = "btnAdd" And Ctrl.Enabled = Not Mode Then
                    Ctrl.Enabled = Mode
                Else
                    Ctrl.Enabled = Mode
                End If
            End If
        Next Ctrl
    End Sub

    Sub SearchSM(ByVal SearchWord As String)
        Try
            If IsConnected() = True Then
                'Queries to database
                If btnsave.Enabled = True Then
                    strSQL = "SELECT * FROM Bookings WHERE StaffID LIKE '" & SearchWord & "%'"
                Else
                    strSQL = "SELECT * FROM Bookings WHERE StaffID LIKE '" _
                         & SearchWord & "%' OR RoomID LIKE '" _
                         & SearchWord & "%' OR [Date required] LIKE '" _
                        & SearchWord & "%' OR [Time required] LIKE '" _
                        & SearchWord & "%' OR [Additional requirements] LIKE '" _
                          & SearchWord & "%'"
                End If
                myCmd.CommandText = strSQL
                myCmd.Connection = myConn
                myDA.SelectCommand = myCmd
                myDR = myCmd.ExecuteReader()

                'Display results to table
                lstStudents.Items.Clear()
                While (myDR.Read())
                    With lstStudents.Items.Add(myDR("StaffID"))
                        .SubItems.Add(myDR("RoomID"))
                        .SubItems.Add(myDR("[Date required]"))
                        .SubItems.Add(myDR("[Time required]"))
                        .SubItems.Add(myDR("[Additional requirements]"))
                    End With
                End While
            End If
        Catch ex As Exception
            MsgBox(ex.Message, , "SearchSM")
        End Try
    End Sub

    '    Private Sub txtSearch_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtSearch.KeyDown
    '       If e.KeyCode = Keys.Return Then
    'Checks first if system is connected then if true, continues to search
    '          If IsConnected() = True Then Call SearchSM(txtSearch.Text)
    '     End If
    'End Sub

    Private Sub frmSM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Locked(True)
        'SetSearchBox()
        SearchSM("")
    End Sub

    'Sub SetSearchBox()
    '   If txtSearch.Text = "" Then
    '      txtSearch.Text = "Type here to search"
    '     txtSearch.ForeColor = Color.Gray
    'End If
    '    End Sub

    '   Private Sub txtSearch_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSearch.LostFocus
    '      SetSearchBox()
    ' End Sub

    ' Private Sub txtSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.Click
    '    If txtSearch.Text = "Type here to search" Then
    '       txtSearch.Text = ""
    '      txtSearch.ForeColor = Color.Black
    ' ElseIf txtSearch.Text <> "" Then
    '    txtSearch.SelectAll()
    'End If
    ' End Sub

    'Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
    'Closes the application
    '   Application.Exit()
    'End Sub


    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
        AddMode = True
        Locked(False)
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
        If stafid.Text <> "" Or rooid.Text <> "" Or date1.Text <> "" Or time1.Text <> "" Or areq.Text <> "" Then
            If IsConnected() = True Then
                SaveEntry(stafid.Text, rooid.Text, date1.Text, time1.Text, areq.Text)
                SearchSM("")
            End If
        Else
            MsgBox("Please fill-up all the fields.", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
        End If
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
        Locked(True)
    End Sub

    Private Sub lstStudents_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstStudents.MouseDoubleClick
        'Displays detailed to textbox for editing
        If btnsave.Enabled = False Then
            Locked(False)
        End If
        With lstStudents.SelectedItems(0)
            Ctrl = .SubItems(0).Text
            stafid.Text = .SubItems(1).Text
            rooid.Text = .SubItems(2).Text
            date1.Text = .SubItems(3).Text
            time1.Text = .SubItems(4).Text
            areq.Text = .SubItems(5).text
        End With
    End Sub

End Class

The problem is :

.SubItems.Add(myDR("RoomID"))
                        .SubItems.Add(myDR("[Date required]"))
                        .SubItems.Add(myDR("[Time required]"))
                        .SubItems.Add(myDR("[Additional requirements]"))
                    End With

here is says
Error 1 'SubItems' is not a member of 'Integer'.

Can Anyone explain whyy??

i need help with this URGENTLY so any help would be much appreciated.... also which method would be most recommended out of the two?

ok sorted that problem it was a listview not listbox... now i gotta problem when i click add and enter the details the save button is not enabled so i cannot save the data so that it can display

anyone?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.