This site is supported by the advertisements on it, please disable your AdBlocker so we can continue to provide you with the quality content you expect.

Visual Basic 2008 help!

Discussion in 'Computers/Gadgets' started by elvis, Aug 12, 2009.

  1. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Not sure if i'll get any replies to this, but i was wondering if anyone knows how to do it, because i need help, i'll go into greater detail and the payment details after there is replies,.

    Note to mods: If there are no replies by Monday i'll remove the thread or one of you can whichever is easier.
     
  2. Benbecul97

    Benbecul97
    Expand Collapse
    Well-Known Member

    Joined:
    Jul 22, 2009
    Messages:
    2,530
    Likes Received:
    64
    I might be able to help - what exactly is it you are trying to do?
     
  3. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Its a project for college repeats, i failed it miserably first time around and its not too much better this time, but its basically an auctioneers database, i cant get my head around it, or the fact i have to do it, seeing as i study Multimedia and finished top of my class besides the VB project which is only for this year.

    I have 4 screens to do, i need t add/delete and edit properties and land to a database from VB. I managed to get the add screen to work, but the edit and delete one didn't then it stopped the add screen from working then i messed it up.
     
  4. Benbecul97

    Benbecul97
    Expand Collapse
    Well-Known Member

    Joined:
    Jul 22, 2009
    Messages:
    2,530
    Likes Received:
    64
    When you say 4 screens to do, do you mean you need to get a screen grab of each screen but first load the necessary data into each screen?

    This is a good VB Tutorial site that may help you:
    http://www.vbtutor.net/vbtutor.html
     
  5. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Sorry that was a term we used in college,. each Screen is basically the menu for each option,. for example Screen 1 is the menu for the project which has buttons, one for add, delete and edit, and one for exit, then whichever you click brings you to the next Screen, so the add new property is Screen2 and so on.
     
  6. Benbecul97

    Benbecul97
    Expand Collapse
    Well-Known Member

    Joined:
    Jul 22, 2009
    Messages:
    2,530
    Likes Received:
    64
    Ok so do you need to write the code in VB? And add/edit/delete the records to/from a DB?
     
  7. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Yes, thats exactly what i need to do,. sorry my explaining wasn't great.
    I had the add records done and working, then i got help with the delete which wouldn't work and no one knew why, then when i tried the edit, it stopped the add from working, also the records never save to the database its access's the database and adds the records, but as soon as i close Visual Studios, and save the database with the new records when i run VS again and add records the database is no blank and the previous records are not there.
     
  8. Benbecul97

    Benbecul97
    Expand Collapse
    Well-Known Member

    Joined:
    Jul 22, 2009
    Messages:
    2,530
    Likes Received:
    64
    Ok. So you have all the code written for each screen - its just that its not working and needs tweaking?

    Do you have any notes/manuals from the year that you can cross-check your code against?
     
  9. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Yeah thats basically it,.
    Regarding manuals all the stuff we covered in lectures was the basics, ie how to close the program etc,. we had to explain to the lecturers how the dispose class works. Apparently thats basic stuff too, i wouldn't know.
    But im more or less in the dark bar the manual that outlines what my project is to do, but there is no code in it,.
     
  10. graham

    graham
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 25, 2009
    Messages:
    3,447
    Likes Received:
    36
    How broken is it exactly at the moment? Does it just need some small tweaks?
    And how did you talk to the database? SQL?
     
  11. Benbecul97

    Benbecul97
    Expand Collapse
    Well-Known Member

    Joined:
    Jul 22, 2009
    Messages:
    2,530
    Likes Received:
    64
    Ok. I could try taking a look at your code if you like - not promising I can sort in now mind you! If you like you can PM it to me.

    When do you need to have this project submitted by?
     
  12. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Need it submitted by the 10th of September.
    I'll find the file and i'll PM it to you in a minute if you dont mind taking a look.
     
  13. graham

    graham
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 25, 2009
    Messages:
    3,447
    Likes Received:
    36
    If yous need any extra help give me a shout
     
  14. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Yeah i used SQL, not sure how broke it is, but it doesnt work, but i reckon its just a few small tweaks because VS is very fussy at times.
     
  15. Benbecul97

    Benbecul97
    Expand Collapse
    Well-Known Member

    Joined:
    Jul 22, 2009
    Messages:
    2,530
    Likes Received:
    64
    Ok. Its a while since I programmed but I'm happy to try and help.

    It might also be no harm sending the code to lint316 - the more heads the better!
     
  16. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Imports System.Data.OleDb

    Public Class DeleteLand

    Private Sub DisplayItemsInListBox(ByVal num As Integer)

    'Loads recordset & outputs to list box

    Dim ConnectionString As String
    Dim SQLString As String
    Dim TitleString As String
    Dim conn As System.Data.OleDb.OleDbConnection
    Dim DataRead As OleDbDataReader
    Dim DbCmd As System.Data.OleDb.OleDbCommand

    ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data "
    ConnectionString += "Source=" & "Auctioneers.accdb "
    ' Another way (using the Application.StartupPath)
    'ConnectionString += "Source=" & Application.StartupPath & "\Auctioneers.accdb "
    conn = New System.Data.OleDb.OleDbConnection(ConnectionString)

    'Access the fields
    SQLString = "SELECT Land_ID, Client_Id, Nature, Street, Town, County, Location FROM Land "
    'SQLString = "SELECT * FROM Books "
    'SQLString += "Where Fiction = TRUE"
    Try 'was database found etc.

    conn.Open()
    If CBool(ConnectionState.Open) Then
    DbCmd = New System.Data.OleDb.OleDbCommand(SQLString, conn)
    DataRead = DbCmd.ExecuteReader()
    If DataRead.HasRows Then
    ' ListboxOutput.Items.Clear()
    While DataRead.Read
    If Not IsDBNull(DataRead.Item("Land_ID")) Then
    TitleString = DataRead.Item("Land_ID") & " " & DataRead.Item("Client_ID") & " " & DataRead.Item("Nature") & " " & DataRead.Item("Street") & " " & DataRead.Item("Town") & " " & DataRead.Item("County") & " " & DataRead.Item("Location")
    ListboxOutput.Items.Add(TitleString)
    End If
    ' Not required
    ' DataRead.Read()
    End While
    End If
    DataRead.Close()
    End If
    Catch
    MessageBox.Show("Error accessing database")
    End Try
    conn.Close()
    ListboxOutput.Items.Add(" ")
    ListboxOutput.Items.Add("Count:" & ListboxOutput.Items.Count - 1)


    End Sub
    Private Sub DeleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteButton.Click

    End Sub
    Private Sub MenuButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuButton.Click
    Dim MainMenu As New Form1
    MainMenu.Show()
    Me.Dispose(False)
    End Sub


    Private Sub ListboxOutput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListboxOutput.SelectedIndexChanged

    Dim ConnectionString As String
    Dim SQLString As String
    Dim DbCmd As System.Data.OleDb.OleDbCommand
    Dim conn As System.Data.OleDb.OleDbConnection
    Dim DataRead As OleDbDataReader
    Dim ISBN As String
    ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data "
    ConnectionString += "Source=" & "Auctioneers.accdb "
    conn = New System.Data.OleDb.OleDbConnection(ConnectionString)




    LandTextbox.Text = ListboxOutput.Text.Substring(0, 13)
    SQLString = "SELECT * FROM Land "
    SQLString += "Where '" & LandTextbox.Text & "'"
    SQLString += "= Land_ID "


    Try
    conn.Open()
    If ConnectionState.Open.ToString = "Open" Then
    DbCmd = New System.Data.OleDb.OleDbCommand(SQLString, conn)
    DataRead = DbCmd.ExecuteReader()
    If DataRead.HasRows Then
    DataRead.Read()
    If Not IsDBNull(DataRead.Item("Land_ID")) Then
    LandTextBox.Text = DataRead.Item("Land_ID").ToString
    End If
    If Not IsDBNull(DataRead.Item("Client_ID")) Then
    ClientTextBox.Text = DataRead.Item("Client_ID").ToString
    End If
    If Not IsDBNull(DataRead.Item("Nature")) Then
    NatureTextBox.Text = DataRead.Item("Nature").ToString
    End If
    If Not IsDBNull(DataRead.Item("Street")) Then
    StreetTextBox.Text = DataRead.Item("Street").ToString
    End If
    If Not IsDBNull(DataRead.Item("Town")) Then
    TownTextBox.Text = DataRead.Item("Town").ToString
    End If
    If Not IsDBNull(DataRead.Item("County")) Then
    CountyTextBox.Text = DataRead.Item("County").ToString
    End If
    If Not IsDBNull(DataRead.Item("Location")) Then
    LocationTextBox.Text = DataRead.Item("Location").ToString
    End If
    End If
    End If
    Catch ex As Exception

    End Try
    End Sub

    Private Sub DeleteLand_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    End Class
     
  17. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Had to put the code here, it was too long for the PM system,.
    Anyway thanks for the help lads.
     
  18. graham

    graham
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 25, 2009
    Messages:
    3,447
    Likes Received:
    36
    yeah fire it onto me lads, I'm a Java programmer. I'm in work right now but I can take a look when I get home this evening. We'll get it working either way for certain.ill PM you my email address
     
  19. F@ces

    F@ces
    Expand Collapse
    Part of the dance

    Joined:
    May 7, 2008
    Messages:
    9,005
    Likes Received:
    8
    So this is an application written in VB.Net (as the old Visual Basic language is depracated) using an MS Access database to display, add, modify and delete data?

    One problem you've mentioned (the data not saving) is more than likely related to the data not being commited. So for example (and dependent on how you've modularised your database manipulation code/classes) you can be doing something like - connect to database (using your connection string), process the transaction (i.e. process SQL string against the database which adds a new record), "accept the changes", and then finally at the end commit the changes. It sounds to me like you are doing all steps except the last; so it appears the record has been added (if there was an issue (i.e. duplicate key for example) then an error would be thrown) but after that you need to commit the changes (i.e. make them permanent). The idea behind this is that you could (for example) create a transaction that processes 1000 new record additions, but only when they are all complete do we "commit" - this way we only do one commit instead of 1000, hence reducing processing time.

    If you literally google what you want to do you should find tons of stuff online (I'm a software developer and the web is simply the best resource).

    If you still need help give me a shout. I don't develop in VB.Net, but do in C#.Net & C++ (however I have developed multiple applications in the old VB, not to mention multiple other legacy and non legacy languages).

    If you get really stuck you could upload the application somewhere and I could have a look at fixing the issues for you mate (as I have VS 2008).

    EDIT: Just seen you posted the code, will take a look when I get a chance.
     
  20. elvis

    elvis
    Expand Collapse
    Well-Known Member

    Joined:
    Apr 17, 2009
    Messages:
    21,902
    Likes Received:
    1,440
    Just thought id stick the download link to the project file.

    http://uploading.com/files/PM5TWL1T/AuctioneersDB.zip.html

    Thanks again to everyone for offering to help, its much appreciated, and if anyone is going to the Liverpool vs Bohs game, i'll buy you's all a pint if you's are around before or after the match, cheers.

    EDIT: It requires you to wait 60 seconds to download if you dont have a premium account.
     
    #20 elvis, Aug 12, 2009
    Last edited: Aug 12, 2009

Share This Page