locked
5 Rating Stars in vb.net with Access 2007

    Question

  • 'I was wondering how to create rating stars in Access 2007 then import back the database to Visual Studio, i dont think its possible, but i just want 'to ask?

    'If not, does anyone know how to make rating stars in Visual Studio then connect back to Access?

    'Any example, thanks

    IT looks like i found a way how, however, how do i save my integer i to Access 2007?

    my code for RATING STARS

      '###########################STAR RATING############
        '
        Private Sub btn_star1_Click(sender As Object, e As EventArgs) Handles btn_star1.Click
            RatingNumericUpDown.Value = 1
            i = 1
            btn_star2.Image = My.Resources.blank
            btn_star3.Image = My.Resources.blank
            btn_star4.Image = My.Resources.blank
            btn_star5.Image = My.Resources.blank
            btn_star1.Image = My.Resources.fill
            For i As Integer = 1 To Me.TableAdapterManager.UpdateAll(Me.EmployeesDataSet)
            Next
        End Sub
    
        Private Sub btn_star2_Click(sender As Object, e As EventArgs) Handles btn_star2.Click
            RatingNumericUpDown.Value = 2
            i = 2
            btn_star1.Image = My.Resources.fill
            btn_star2.Image = My.Resources.fill
            btn_star3.Image = My.Resources.blank
            btn_star4.Image = My.Resources.blank
            btn_star5.Image = My.Resources.blank
            For i As Integer = 2 To Me.TableAdapterManager.UpdateAll(Me.EmployeesDataSet)
            Next
    
        End Sub
    
        Private Sub btn_star3_Click(sender As Object, e As EventArgs) Handles btn_star3.Click
            RatingNumericUpDown.Value = 3
            i = 3
            btn_star1.Image = My.Resources.fill
            btn_star2.Image = My.Resources.fill
            btn_star3.Image = My.Resources.fill
            btn_star4.Image = My.Resources.blank
            btn_star5.Image = My.Resources.blank
            For i As Integer = 2 To Me.TableAdapterManager.UpdateAll(Me.EmployeesDataSet)
            Next
        End Sub
    
    
        Private Sub btn_star4_Click(sender As Object, e As EventArgs) Handles btn_star4.Click
            RatingNumericUpDown.Value = 4
            i = 4
            btn_star1.Image = My.Resources.fill
            btn_star2.Image = My.Resources.fill
            btn_star3.Image = My.Resources.fill
            btn_star4.Image = My.Resources.fill
            btn_star5.Image = My.Resources.blank
            For i As Integer = 2 To Me.TableAdapterManager.UpdateAll(Me.EmployeesDataSet)
            Next
    
        End Sub
    
    
        Private Sub btn_star5_Click(sender As Object, e As EventArgs) Handles btn_star5.Click
            RatingNumericUpDown.Value = 5
            i = 3
            btn_star1.Image = My.Resources.fill
            btn_star2.Image = My.Resources.fill
            btn_star3.Image = My.Resources.fill
            btn_star4.Image = My.Resources.fill
            btn_star5.Image = My.Resources.fill
            For i As Integer = 2 To Me.TableAdapterManager.UpdateAll(Me.EmployeesDataSet)
            Next
        End Sub

    now, the question is i want to save the i everytime into my access 2007 (my dtb)

    For i As Integer = 2 To Me.TableAdapterManager.UpdateAll(Me.EmployeesDataSet)
            Next

    i know the above code is wrong.. XD



    Rich


    • Modifié Rich Wang jeudi 20 décembre 2012 21:49
    jeudi 20 décembre 2012 03:30

Réponses

  • Hello,

    If using VS2010 or higher download this project which uses a custom DataGridView column done in C Sharp and the sample project is in VB.NET. If this works for you simply study how I put things together i.e. DataGridView columns are added in the IDE, each column's DataProperty is set to a field in the underlying MS-Access database table.

    IMPORTANT NOTE I am so use to posting for versions of VS higher than Express I forgot that you can't use VB and C in one solution. To solve this simple load the VB.NET project and then under project references add a reference to the DLL in the bin\debug folder of the column project then compile/run the VB.NET project.

    To keep things simple I read data on form load and by pressing the save button update rows in the backend database. I did not include code for adding or deleting rows which would be easy enough.

    Caveat, note when looking at the code how the save operation is done and if you press the close button are prompted to lose or save changes. I did not include code for the system red x so if you use that button to close it bypasses the close button logic, this was to keep focus on the issue of ratings.

    If you don't like colors of the stars you have full source to alter them.

    Lastly since this differs from how you are loading data if you take time to study the code you should have no problem translating my code methods to yours or perhaps use my method of working with the data.


    KSG


    samedi 5 janvier 2013 00:23

Toutes les réponses

  • HI

    Can you explain what is the meanning of this line?

     Me.TableAdapterManager.UpdateAll(Me.EmployeesDataSet)
    

    Why you treat the result of this line to be a integer and use it in a loop?

    if you use the code, just update the interger "i" to the specific column in database table.

    if you use the datasource wizard, set the i to the textbox bound with the specific column in database table.


    No code, No fact.

    vendredi 21 décembre 2012 03:18
  • That one just update the record of i. i suppose to be 1 - 5 not 2 each time, my bad.

    I want to save the integer i to my data base in access. 


    Rich

    vendredi 21 décembre 2012 03:20
  • I don't have an answer for updating access, as I do not use it. But I see that you can reduce the amount of code to update your star system.

    Option Strict On
    Public Class Form1
        Dim i As Integer
        Private Sub starPB1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles starPB1.MouseDown, starPB2.MouseDown, starPB3.MouseDown, starPB4.MouseDown, starPB5.MouseDown
            If sender Is starPB1 Then RatingNumericUpDown.Value = 1 : i = 1
            If sender Is starPB2 Then RatingNumericUpDown.Value = 2 : i = 2
            If sender Is starPB3 Then RatingNumericUpDown.Value = 3 : i = 3
            If sender Is starPB4 Then RatingNumericUpDown.Value = 4 : i = 4
            If sender Is starPB5 Then RatingNumericUpDown.Value = 5 : i = 5
            If i > 0 Then starPB1.BackgroundImage = My.Resources.Fill Else starPB1.BackgroundImage = My.Resources.blank
            If i > 1 Then starPB2.BackgroundImage = My.Resources.Fill Else starPB2.BackgroundImage = My.Resources.blank
            If i > 2 Then starPB3.BackgroundImage = My.Resources.Fill Else starPB3.BackgroundImage = My.Resources.blank
            If i > 3 Then starPB4.BackgroundImage = My.Resources.Fill Else starPB4.BackgroundImage = My.Resources.blank
            If i > 4 Then starPB5.BackgroundImage = My.Resources.Fill Else starPB5.BackgroundImage = My.Resources.blank
            '      For i As Integer = 1 To Me.TableAdapterManager.UpdateAll(Me.EmployeesDataSet)
            '     Next
        End Sub
    End Class


    If you want something you've never had, you need to do something you've never done.

    Everyone should take the time to mark helpful posts and propose answers!

    Answer an interesting question?
    Create a wiki article about it!

    My Technet Wiki Articles


    mardi 1 janvier 2013 14:22
    Modérateur
  • Thats another way to approach it! Nice, but i need to save the integer i to my database.. I got the update part. 

    I am still looking for an answer, if not this thread should be close sooner or later. 


    Rich

    mercredi 2 janvier 2013 00:41
  • Thats another way to approach it! Nice, but i need to save the integer i to my database.. I got the update part. 

    I am still looking for an answer, if not this thread should be close sooner or later. 


    Rich

    Try reading this tutorial, see if it helps shed some light for you.

    http://www.geekpedia.com/tutorial158_Connect-to-Access-Database-in-Visual-Studio-.NET.html


    If you want something you've never had, you need to do something you've never done.

    Everyone should take the time to mark helpful posts and propose answers!

    Answer an interesting question?
    Create a wiki article about it!

    My Technet Wiki Articles

    mercredi 2 janvier 2013 00:47
    Modérateur
  • images doesnt load.. its okay. 

    So currently no answer.

    -1/3/13


    Rich

    vendredi 4 janvier 2013 03:14
  • Hello,

    If using VS2010 or higher download this project which uses a custom DataGridView column done in C Sharp and the sample project is in VB.NET. If this works for you simply study how I put things together i.e. DataGridView columns are added in the IDE, each column's DataProperty is set to a field in the underlying MS-Access database table.

    IMPORTANT NOTE I am so use to posting for versions of VS higher than Express I forgot that you can't use VB and C in one solution. To solve this simple load the VB.NET project and then under project references add a reference to the DLL in the bin\debug folder of the column project then compile/run the VB.NET project.

    To keep things simple I read data on form load and by pressing the save button update rows in the backend database. I did not include code for adding or deleting rows which would be easy enough.

    Caveat, note when looking at the code how the save operation is done and if you press the close button are prompted to lose or save changes. I did not include code for the system red x so if you use that button to close it bypasses the close button logic, this was to keep focus on the issue of ratings.

    If you don't like colors of the stars you have full source to alter them.

    Lastly since this differs from how you are loading data if you take time to study the code you should have no problem translating my code methods to yours or perhaps use my method of working with the data.


    KSG


    samedi 5 janvier 2013 00:23
  • Wow, this is really good, wow. I did mine with the buttons using detail view. 

    Thanks!


    Rich

    samedi 5 janvier 2013 00:39
  • Your welcome.

    KSG

    samedi 5 janvier 2013 00:48
  • Kevin,

    did you create it or it was from a website? If so i would like to have some step by step instructions... I want to remake mine... This sample looks so professional!

    Thanks


    Rich

    samedi 5 janvier 2013 01:00
  • I did not create the column/cell classes, the original source is in the readme.txt file included. I wrote the demo project about 15 minutes after reading your post here.

    The basic steps are

    1. Add the DLL project under project references in your project.
    2. Place a DataGridView on a form
    3. In the upper right corner of the DataGridView click the chevron button.
    4. Add a new column of type RatingColumn
    5. Now edit the column, set the DataPropertyName to the field name that contains the values for the rating field (a numeric field)
    6. Add other columns to the DataGridView, set the column type, DataPropertyName
    7. Load your data (let's say a DataTable) into a BindingSource which becomes the DataSource of the DataGridView.
    8. Assign the BindingSource to the DataSource property of the DataGridView.

    I think that is everything. I like using a BindingSource because of added functionality. If you also add a BindingNavigator you have even more functionality.

    If you want more information (since I used it in the project) on DataTable events download the following VS2010 project.

    Ratings column author Mark Rideout, source at http://blogs.msdn.com/b/markrideout/archive/2006/01/18/media-player-like-rating-datagridview-column.aspx


    KSG

    samedi 5 janvier 2013 01:14