What to do?  Visual basic.net
What to do?  Visual basic.net
What to do?  Visual basic.net
What to do?  Visual basic.net
What to do?  Visual basic.net
What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net
What to do?  Visual basic.net What to do?  Visual basic.net
What to do?  Visual basic.net
Go Back  Xtreme Visual Basic Talk > > > What to do? Visual basic.net


Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2004, 08:41 PM
VBPOWERHOST VBPOWERHOST is offline
Freshman
 
Join Date: Sep 2004
Posts: 40
Default What to do? Visual basic.net


I am trying to write a program that will handle the inventory control of New Units at a motorcycle dealership that has 4 product lines.
Question:What is the best method of storing the data?

To be honest I was thinking of ms access but can't get it to work
I need to be able to add,update to sold, and Transfer Units

I have this accomplished using php,mysql. Any way to use the mysql database without the mysql server installed?
Reply With Quote
  #2  
Old 09-17-2004, 07:47 AM
lebb's Avatar
lebbWhat to do?  Visual basic.net lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

I'm not sure about mySQL, personally, but if you'd like to post the Access code you're having trouble with, we can probably help you fix it.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #3  
Old 09-17-2004, 08:23 AM
VBPOWERHOST VBPOWERHOST is offline
Freshman
 
Join Date: Sep 2004
Posts: 40
Default

Access and mysql problems
Value of type '1-dimensional array of Inventory.DataSet3' cannot be converted to 'Inventory.DataSet3'.

Code giving problem is in bold
Code:
objDataSet3Temp = objService.FillDataSet
Value of type 'Inventory.DataSet3' cannot be converted to '1-dimensional array of Inventory.DataSet3'.

Code giving problem is in bold
Code:
Public Function FillDataSet() As Inventory.DataSet3()
        Dim yamcruiser As New Inventory.DataSet3
        Me.OleDbConnection1.Open()
        Try
            Me.OleDbDataAdapter1.Fill(yamcruiser)
        Catch fillException As System.Exception
            MsgBox("Caught exception: " & fillException.Message)
        End Try
        Me.OleDbConnection1.Close()
        Return yamcruiser
    End Function
Reply With Quote
  #4  
Old 09-17-2004, 08:44 AM
lebb's Avatar
lebbWhat to do?  Visual basic.net lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

What is Inventory.DataSet3? Why not use a standard System.Data.Dataset?
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #5  
Old 09-17-2004, 10:12 AM
VBPOWERHOST VBPOWERHOST is offline
Freshman
 
Join Date: Sep 2004
Posts: 40
Default

will be more datasets if I can figure this out
Reply With Quote
  #6  
Old 09-17-2004, 10:26 AM
lebb's Avatar
lebbWhat to do?  Visual basic.net lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

I don't understand what you mean.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #7  
Old 09-17-2004, 07:10 PM
VBPOWERHOST VBPOWERHOST is offline
Freshman
 
Join Date: Sep 2004
Posts: 40
Default

That is the only way I know to do it at the moment
Reply With Quote
  #8  
Old 09-17-2004, 08:00 PM
lebb's Avatar
lebbWhat to do?  Visual basic.net lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Again, I don't know what Inventory.DataSet3 is. I would expect it to look more like this:

Code:
Public Function FillDataSet() As System.Data.DataSet Dim yamcruiser As New System.Data.DataSet Me.OleDbConnection1.Open() Try Me.OleDbDataAdapter1.Fill(yamcruiser) Catch fillException As System.Exception MsgBox("Caught exception: " & fillException.Message) End Try Me.OleDbConnection1.Close() Return yamcruiser End Function

In particular, note that the parameter to the Fill() method is of a data type supported by that method, and that the variable we're returning is of the same type as the function is declared as.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #9  
Old 09-17-2004, 08:28 PM
VBPOWERHOST VBPOWERHOST is offline
Freshman
 
Join Date: Sep 2004
Posts: 40
Default

with that setup I get an error message "specified class is not valid"
when trying to load the data from the database
Reply With Quote
  #10  
Old 09-17-2004, 08:48 PM
lebb's Avatar
lebbWhat to do?  Visual basic.net lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Specified class, or specified cast? On what line?
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #11  
Old 09-17-2004, 09:14 PM
VBPOWERHOST VBPOWERHOST is offline
Freshman
 
Join Date: Sep 2004
Posts: 40
Default

cast and it doesn't say what line its when I run the program no build errors at all either
Reply With Quote
  #12  
Old 09-17-2004, 09:20 PM
lebb's Avatar
lebbWhat to do?  Visual basic.net lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Are you running it in VS? If so, it should break at some particular line. Sorry, but I'm flying blind here -- not even enough information for a wild guess.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #13  
Old 09-17-2004, 10:27 PM
VBPOWERHOST VBPOWERHOST is offline
Freshman
 
Join Date: Sep 2004
Posts: 40
Default

Ok the program is built in visual studio.net visual basic I am trying to access,add,update an access database with it and the first code set wouldn't build the second (posted) code set works when built but when you click the load button you get the error on a popup diaglox box.
Reply With Quote
  #14  
Old 09-18-2004, 10:44 AM
MKoslof's Avatar
MKoslofWhat to do?  Visual basic.net MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

Ok, take a step back or two . Did you look at Lebb's post, number #8? Are you trying to use an OLEDBConnection and data methods? If so, have you added the proper import statements? Have you defined a proper NEW instance of the command, dataAdapter and connection object?

And if you are using MySQL (sorry this is still not clear), you might want to go to the MySQL homepage and download one of their .Net specific data drivers. "Corelab" is a popular one I believe.
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #15  
Old 09-18-2004, 01:36 PM
lebb's Avatar
lebbWhat to do?  Visual basic.net lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Let's try this one step at a time. You're in Visual Studio .NET (whether it's VB.NET Standard or Pro won't make any difference, so nevermind that). You have your project open, including my code above. You click the Start button on the toolbar (or go to Debug > Start, or press F5, whichever method suits your fancy). You get the cast exception. You press Break. What line is highlighted?
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #16  
Old 09-18-2004, 01:44 PM
VBPOWERHOST VBPOWERHOST is offline
Freshman
 
Join Date: Sep 2004
Posts: 40
Default

I get the cast exception when loading the data from the database in the program at runtime.
Reply With Quote
  #17  
Old 09-18-2004, 02:02 PM
lebb's Avatar
lebbWhat to do?  Visual basic.net lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

That's all very nice, but doesn't answer my question.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
  #18  
Old 09-18-2004, 03:13 PM
MKoslof's Avatar
MKoslofWhat to do?  Visual basic.net MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

1) Post your exact code as it stands now..include any import statements you are implementing.
2) Run your code in debug mode..tell us what line you are receiving this error on.
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #19  
Old 09-18-2004, 04:36 PM
VBPOWERHOST VBPOWERHOST is offline
Freshman
 
Join Date: Sep 2004
Posts: 40
Default

Form1 code
Code:
 Public Function FillDataSet() As System.Data.DataSet
        Dim yamcruiser As New System.Data.DataSet
        Me.OleDbConnection1.Open()
        Try
            Me.OleDbDataAdapter1.Fill(yamcruiser)
        Catch fillException As System.Exception
            MsgBox("Caught exception: " & fillException.Message)
        End Try
        Me.OleDbConnection1.Close()
        Return yamcruiser
    End Function
    Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click

    End Sub

    Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
        Dim dataform1 As New DataForm1
        dataform1.Show()
    End Sub

    Private Sub MenuItem14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem14.Click
        Me.Close()
    End Sub
End Class
dataform1 code
Code:
 Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.BindingContext(objDataSet1, "yamcruiser").CancelCurrentEdit()

    End Sub
    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        If (Me.BindingContext(objDataSet1, "yamcruiser").Count > 0) Then
            Me.BindingContext(objDataSet1, "yamcruiser").RemoveAt(Me.BindingContext(objDataSet1, "yamcruiser").Position)
        End If

    End Sub
    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Try
            'Clear out the current edits
            Me.BindingContext(objDataSet1, "yamcruiser").EndCurrentEdit()
            Me.BindingContext(objDataSet1, "yamcruiser").AddNew()
        Catch eEndEdit As System.Exception
            System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
        End Try

    End Sub
    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Try
            'Attempt to update the datasource.
            Me.UpdateDataSet()
        Catch eUpdate As System.Exception
            'Add your error handling code here.
            'Display error message, if any.
            System.Windows.Forms.MessageBox.Show(eUpdate.Message)
        End Try

    End Sub
    Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
        Try
            'Attempt to load the dataset.
            Me.LoadDataSet()
        Catch eLoad As System.Exception
            'Add your error handling code here.
            'Display error message, if any.
            System.Windows.Forms.MessageBox.Show(eLoad.Message)
        End Try

    End Sub
    Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelAll.Click
        Me.objDataSet1.RejectChanges()

    End Sub
    Public Sub UpdateDataSet()
        'Create a new dataset to hold the changes that have been made to the main dataset.
        Dim objDataSetChanges As Inventory.DataSet1 = New Inventory.DataSet1
        Dim objDataSetUpdated As System.Data.DataSet = New Inventory.DataSet1
        'Stop any current edits.
        Me.BindingContext(objDataSet1, "yamcruiser").EndCurrentEdit()
        'Get the changes that have been made to the main dataset.
        objDataSetChanges = CType(objDataSet1.GetChanges, Inventory.DataSet1)
        'Check to see if any changes have been made.
        If (Not (objDataSetChanges) Is Nothing) Then
            Try
                'There are changes that need to be made, so attempt to update the datasource by
                'calling the update method and passing the dataset and any parameters.
                objDataSetUpdated = Me.objDataSet1.Clone
            Catch eUpdate As System.Exception
                'Add your error handling code here.
                Throw eUpdate
            End Try
            'Add your code to check the returned dataset for any errors that may have been
            'pushed into the row object's error.
            Try
                objDataSet1.Merge(objDataSetUpdated)
            Catch eUpdateMerge As System.Exception
                'Add exception handling code here
                Throw eUpdateMerge
            End Try
            'Commit the changes that were just merged
            'This moves any rows marked as updated, inserted or changed to being marked as original values
            objDataSet1.AcceptChanges()
        End If

    End Sub
    Public Sub LoadDataSet()
        'Create a new dataset to hold the records returned from the call to FillDataSet.
        'A temporary dataset is used because filling the existing dataset would
        'require the databindings to be rebound.
        Dim objDataSetTemp As Inventory.DataSet1
        objDataSetTemp = New Inventory.DataSet1
        Try
            'Attempt to fill the temporary dataset.
            objDataSetTemp = CType(Me.objDataSet1.Clone, Inventory.DataSet1)
        Catch eFillDataSet As System.Exception
            'Add your error handling code here.
            Throw eFillDataSet
        End Try
        Try
            'Empty the old records from the dataset.
            objDataSet1.Clear()
            'Merge the records into the main dataset.
            objDataSet1.Merge(objDataSetTemp)
        Catch eLoadMerge As System.Exception
            'Add your error handling code here.
            Throw eLoadMerge
        End Try

    End Sub
End Class
Reply With Quote
  #20  
Old 09-18-2004, 04:41 PM
lebb's Avatar
lebbWhat to do?  Visual basic.net lebb is offline
Disillusioned Code Poet

Retired Moderator
* Guru *
 
Join Date: Apr 2002
Location: Tennessee, USA
Posts: 12,808
Default

Quote:
Originally Posted by lebb
On what line?
Quote:
Originally Posted by lebb
...it should break at some particular line.
Quote:
Originally Posted by lebb
You get the cast exception. You press Break. What line is highlighted?
Quote:
Originally Posted by MKoslof
2) Run your code in debug mode..tell us what line you are receiving this error on.
We'd love to help, but we aren't mind-readers.
__________________
Laura

Ita erat quando hic adveni.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
What to do?  Visual basic.net
What to do?  Visual basic.net
What to do?  Visual basic.net What to do?  Visual basic.net
What to do?  Visual basic.net
What to do?  Visual basic.net
What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net What to do?  Visual basic.net
What to do?  Visual basic.net
What to do?  Visual basic.net
 
What to do?  Visual basic.net
What to do?  Visual basic.net
 
-->