TomW 73 Posting Whiz

A little more detail about what isnt working would be helpful. Also you should properly declare instances of each for you want to create.

Private Sub LoadForm3( )

    Dim frm As New Form3
    frm.Show()

End Sub
TomW 73 Posting Whiz

I have already answered this with an example on the other board you posted the same question

TomW 73 Posting Whiz

The record is either added/inserted to the dataset/datatable or it is not. AcceptChanges will only change the rowstate (if it already exists in the dataset) of the record from New to Unchanged and will then prevent the record from then being saved to the database since the datatable sees it as unchanged.

Iammirko can you show an example of how your checking if this record is inserted? Also I dont see in this example where your creating an instance of this dataset and pointing the table adapter to it.

TomW 73 Posting Whiz

Lots of different ways you can do the import but automatting Excel is probably the last one I would pick. First if you are importing directly from an Excel file, there is no reason to automate Excel at all. Using OLEDB you can read the values straight from the file into a dataset/datatable. This has an added advantage of not needing the user to also have the same version of Excel installed on the computer. Second there is no need to convert a CSV file before doing an import, there are many methods available for reading/importing delimited files. Not that it matters but you mention your using ODBC to read the Excel file, I dont see ODBC being used at all in your example.

I would suggest starting out by taking a look at the "TextFieldParser" in the help file. It has full examples for reading delimited files without the need to convert them to a different format.

TomW 73 Posting Whiz

Seem to be that it is expecting you to pass an integer value in the c.GetDisplayText function but instead you are passing a tab string. Of course im only taking a guess here since I dont know what your function parameters are...

TomW 73 Posting Whiz

None of the parameters even have datatypes defined.... An overflow error is usually caused by trying to force a bad value that doesnt fit into a specific datatype.

TomW 73 Posting Whiz

Time will automatically be applied as 12am thats why its better to use a between statement to give you all records for the specified day.

TomW 73 Posting Whiz

Also dont forget to include the # signs surrounding your date

TomW 73 Posting Whiz

Database's hold a DateTime value so its important to include the time such as using a between Todays date at 12:00am and tomorrows date

TomW 73 Posting Whiz

The field parameters seem to be correct unless im missing a misspelling somewhere between them. I would start by making two changes and see if you still have the same problem.

01) Convert the @DesignationID into an in (CInt(TxtDesigCode.Text))
02) Remove assigning them into PARAM (no clue what that is even doing there or where you are using it. However cmd is your command object and adding the parameters directly to that is all that is needed.

Last suggest is while stepping through the code, see exactly what values are being passed at the time of execution. If you are still having problems please give more detail to the error message that you are receiving.

TomW 73 Posting Whiz

Can you show your insert statement from the stored procedure? Without seeing it, I'm guessing either the parameters are wrong, missing or misspelled.

Also assuming that DesignationID is an numeric field I would suggest converting the textbox value to a numeric datatype (CInt(TxtDesigCode.Text))

Lastly there is no need of assigning anything to Param (Param = ...) change that so it just starts with the cmd.Parameters.AddWithValue(...

TomW 73 Posting Whiz

Leo, yes you can (and should) store the path and retrieve it and use that to load your images. To backtrack, you can upload pictures to the database (it is possible) but is a very bad practice to do so for reasons mentioned above. I'm glad you are reasonable enough to take the suggestions and opt to use a more efficient method.

As to your question, it is very general. What exactly do you need help with, creating a connection string, executing a query, loading the image?
Here is a link that will provide a lot of usefull examples for database programming from the MSDN:
Data Walkthroughs

TomW 73 Posting Whiz

I would need more details in order to help. What database are you using, what is you connection string etc.... Mark this thread as solved and start a new one about the connection strings and I will see if I can help.

TomW 73 Posting Whiz

Glad to help. Sorry there isnt an easier way or atleast one that I can find, I definitely need to accomplish the same thing for some forms. There is also one other way I know of that consists of using subreports. I didnt think to mention it because I have discounted them myself previously, too slow to load and print...

TomW 73 Posting Whiz

Glad it worked. You should have gotten a more clear descriptive error msg.... :(

TomW 73 Posting Whiz

Is this something you can upload including the db, so I can take a look at it?

TomW 73 Posting Whiz

Well in that update statement alone, the only think I can think of is UserName as being null when not expected, Did you change the column name Sales Orders in your database to be a single word? This has to match exactly? And I can picture an order number having a decimal point, are your sure the datatype in your database is the same? Lastly LockedForEdit is a string datatype in the db?

TomW 73 Posting Whiz

What is UserName and where is it coming from?

TomW 73 Posting Whiz

Saving pictures to a database isnt optimal and should be avoided if possible. Including pictures can greatly increase the size of your database and reduce the speed of its processing. Likewise everytime you update a record that contains a picture, even if your not touching the column with the picture, that record size is doubled in your db making it continue to grow.

It is much better to store the path of your picture in a database column and use that path to load your pictures when needed.

TomW 73 Posting Whiz

If you need any help just let me know. My example sends the report directly to the printer without displaying it on the screen first, but the same applies, set the footer size before displaying the reportviewer.

In case I made the above sound more complicated then it is, basically all Im doing is using the blank footer space to emulate the white space of any missing records so that in appearance the details section appears to be a fixed size.

I cant believe that there wasnt an easier solution to this but as said, I had the same problem and spent time researching it and this is the best that I could come up with for resolving the problem.

TomW 73 Posting Whiz

Just went through this exact situation a few weeks ago myself. Suprisingly there is not an easy solution for this although I did find a work around.

There is no way to set the total height of the details section iteself, only the height of the individual item records. So the first thing you want to do is calculate the indivual record height and then the total for all 10 records. So say the height is 136 for each individual details record, total for 10 shown records should equal 1,360.

Ok under the details section add a Footer section to the report. If you are actually using a footer section, you can add an additional footer. You just want to make sure this blank footer is directly underneath the details section. Set this new blank footer to your total size: 1,360

Now Im not sure how your report is set us to draw the data. Are you allowing the report itself to query directly from the database or passing it a filled dataset? I'm doing the latter. Either way before you display the report you need to know how many records will be displayed so you can adjust the height programmiticaly.

Now the footer does allow us to adjust its height from VB. So I'm creating a blank section that would appear to be the size of 10 records if no records at all were returned. Now what we want to do is shrink this footer …

TomW 73 Posting Whiz

I dont think this is your problem but your use of transactions is incorrect. In order for a transaction to work you either have to commit the changes or roll them back if it errors which I dont see being done.

The only other mistake I see is "Sales Order" if you have a space in your column name words, you much enclose the column name in brackets. [Sales Order]

TomW 73 Posting Whiz

A messagebox should not be returning a value of zero. It is better to use the DialogResult constants to see what the values mean but again either way none of these values should be zero. Even clicking on the X button in the top right corner would return a default value.

Dialog Returned Values:
OK : 1
Cancel : 2
Abort : 3
Retry : 4
Ignore : 5
Yes : 6
No : 7

Private Sub Button1_Click(...) Handles Button1.Click

        Dim dlgResult As DialogResult = Nothing

        dlgResult = MessageBox.Show("Do you want to continue?" _
                                    , "Msg Caption" _
                                    , MessageBoxButtons.YesNoCancel _
                                    , MessageBoxIcon.Question)

        'Display selected values from previous messagebox
        MessageBox.Show(String.Format( _
                        "dlgResult String Value : {0}{1}" & _
                        "dlgResult Numeric Value: {2}" _
                        , dlgResult.ToString _
                        , ControlChars.NewLine _
                        , CInt(dlgResult)))

End Sub

If you need anymore help just let me know.

TomW 73 Posting Whiz

Wow the command builder is creating that statement? It has a parameter (?) where a field name should be and its leaving spaces between multi word field names without placing brackets around it. Where is the begining of the statement, Update Table / Insert etc?

To get a more detailed description of your query statement, add a line of code between the GetUpdateCommand and Adapter.Update lines, msgbox(Adapter.UpdateCommand.ToString)

I think it might be easier to dump the command builder (but I have a bias to command builders, always problematic) and just add your own Insert & Update statements to the data adapter. I can show you how if you need help.

Ok its a bit difficult to offer suggestions since I dont know what the rest of your program is doing but from the code snippet shown, your retrieving all records in a table just to update a single record? If thats the case, can we just execute an update statement directly to the database without even the need to return all records first?

Can you give me a summary of what the form is doing overall and the usuage of this update? Is it a one time update or something done multiple times or throughtout multiple records etc?

TomW 73 Posting Whiz

When you call a datasets AcceptChanges method it automatically sets all rows to unmodified, removing and new, updated or deleted work you did to the dataset... So by the time you call update a few lines later, theres nothing to update

Also when you use a dataadapter, you dont have to explicitly open & close the db connection, the dataadapter will automatically do it for you.

Not sure why your disposing of your dataset after updating but then filling it right after that. Also I dont know what values are in your dataset or what your SearchResults function is doing to help much further about your label problem.

TomW 73 Posting Whiz
Dim ds As New DataSet

Using con As New SqlConnection(strDbConnectionHere)
    Dim cmd As New SqlCommand
    Dim da As SqlDataAdapter = Nothing

    cmd.Connection = con
    cmd.CommandText = "Select * From Member Order By Names"

    da = New SqlDataAdapter(cmd)
    da.Fill(ds, "Member")

    da.Dispose()
    cmd.Dispose()
End Using

ListBox2.DataSource = ds.Tables("Member") 'Binds the table to your listbox
ListBox2.DisplayMember = "Name" 'The col in the tbl you want to display

Just replace the sql objects with the equivelent OLEDB objects

Dorayaki commented: Thanks +2
TomW 73 Posting Whiz

A bit different but I wanted to offer a suggestion. You are first querying the DB and manually entering each name into your listbox and then re-querying the DB when a selection is made to get the specified record.

I'm thinking that it would be easier and more efficient if you just filled a dataset table to start, bind the name column to the listbox without having to itterate thru a loop of all records and when a selection is made, you only need to filter your existing datatable in memory rather then requerying the database for the record. Storing the results in a dataset would also be benificial for changes to the records (delete, update, insert etc)

However the size of your database would determine whether or not this would be optimal, I wouldnt suggest keeping that many records in memory for instance if there were tens of thousands of records to choose from. But at the same time I wouldnt recommend filling a listbox that large either... :)

kvprajapati commented: Good suggestion. +6
TomW 73 Posting Whiz

You can use a select statement to fill a DataSet/DataTable. You can then export the entire dataset to an xml file with a single call, youDataSet.WriteXml(strYourFileNameAndPath)

Exporting to a text file is a bit more involved, you have to loop thru each of the records in the datatable to extract each column field and format your line object to use the StreamWriter.

TomW 73 Posting Whiz
Private Sub btnclearall_Click

Dim ctl As New Control

For Each ctl In Me.Controls
Next

'Ok above you looped through all controls on your form but did
'nothing with each itteration

'Now below is only checking one single control, the last one of your form
If Typeof ctl Is textbox Then

    'Above you detemined ctl, is a texbox, so why are
    'you creating a new text box and converting the 
    'the existing textbox into another textbox?
    Dim txtcontrol As Textbox = Directcast (ctl.Textbox)


    'Me is the form you are in, so the only thing
    'you are changing is the text propert of the form itself
    'not any of the text boxes.
    Me.text = StringEmpty

See Rogachev's post above which shows how to correctly itterate thru the controls and clear the textboxes as it goes. But as an additional note, the coding provided will not itterate thru child controls within a container control. For example if you have a few panels and/or group boxes you would need to itterate thru each seperatly to find each of the child controls.

TomW 73 Posting Whiz

You need to be storing these individual values into numeric variables to be calculated at the end.

'Radio Choice
Selection

Dim decRadioPrice As Decimal

        Console.WriteLine("Please enter the Radio Choice for your vehicle: ")
        Console.WriteLine("Enter 1 for AM/FM Radio")
        Console.WriteLine("Enter 2 for AM/FM/CD/DVD")
        strRadioChoice = Console.ReadLine()
        Select Case strRadioChoice
            Case "1"
                Console.WriteLine("Price : $100")
                decRadioPrice = 100.00
            Case "2"
                Console.WriteLine("Price : $400")
                 decRadioPrice = 400.00
            Case Else
                Console.WriteLine("Invalid selection")

        End Select

        'SellingPrice = BasePrice + strEngineChoice + strInteriorChoice 
        '+ strRadioChoice + ShippingCharge + DealerCharge
 
         decTotal = decBasePrice + desEnginePrice + decInterior + decRadio etc
        Console.WriteLine("The total selling price for your vehicle is $" + FormatCurrencty(decTotal))
        Console.WriteLine()
        Console.WriteLine("Press Enter to Exit")
        Console.ReadLine()
JRabbit2307 commented: thanks this solved it! +1
TomW 73 Posting Whiz

This is a console app or is that just for your example? If a console app, I would start by displaying a list of the choices they have to pick from with an item/row number starting each line and then asking for them to type that item/row number in for the input. Also remember what is read/written is already text even if there writing a number...

Dim strEngineChoice As String = ""

        Console.WriteLine("Enter 1 for six cylinder")
        Console.WriteLine("Enter 2 for eight cylinder")
        Console.WriteLine("Enter 3 for disel")

        strEngineChoice = Console.ReadLine

        Select Case strEngineChoice
            Case "1"
                Console.WriteLine("Price : $150")
            Case "2"
                Console.WriteLine("Price : $475")
            Case "3"
                Console.WriteLine("Price : $750")
            Case Else
                Console.WriteLine("Invalid selection")
        End Select
TomW 73 Posting Whiz

The problem with the above statement is this loop will run constantly looking for this new value. You could change this to a timer event where you can set the interval of how often it checks to see if the value has change but again this is something that will run in the background until it either finds the changed value or is explicitily coded to turn off. I prefer not to have things such as this run in the background whenever possibile (although sometimes it may be unavoidable). I'm not sure what your app is doing but if possible I would suggest something where the user clicks a control on your form when there ready to get/save the changes.

TomW 73 Posting Whiz

Although you can upgrade some projects it doesnt really convert them to .Net. You are better off starting a new .Net project and just using the old project as a guideline for what needs to be recreated.

TomW 73 Posting Whiz
TomW 73 Posting Whiz

That would be caused by a value within the textbox unable to be converted. I have two suggestions for this, the first which is the better solution may not be allowed by your class assignment and that is to use a NumericUpDown control instead of a textbox. It works the same as a textbox but only allows users to enter numbers and it returns a decimal value. My second suggestion for this would be to use Decimal.TryParse or Double.TryParse, both have examples in the help file, if you still need help with that let me know. (I would suggest using decimal over double for currency values)

Im at work now myself so it is hard for me to go line by line & figure out what your coding is doing.

TomW 73 Posting Whiz
If radPackageA.Checked = True Then
        dblAmountDue = 9.95

        If (dblHoursUsed > 10) Then
                dblAmountDue = 9.95 + (dblHoursUsed - 10) * 2.0
        End If
        lblTotalAmountDue.Text = CStr(dblAmountDue)

ElseIf radPackageB.Checked = True Then
        dblAmountDue = 14.95
ElseIf (dblHoursUsed > 20) Then
        dblAmountDue = 14.95 + (dblHoursUsed - 20) * 1.0

        If radPackageC.Checked = True Then
                dblAmountDue = 19.95
        Else(nonprofit) Then
                dblAmountDue = dblAmountDue * decDiscountRate
        End If

        ' Display the amount due.
        lblTotalAmountDue.Text = CStr(dblAmountDue)
End If

The only spot your adding any info back to a label is in the first part of that If statement where radPackageA.Checked = True or if A & B are both not check and Hours are greate then 20

TomW 73 Posting Whiz

If all is working please mark the thread as solved.

TomW 73 Posting Whiz

Glad to help.

Well if you use a loop instead of a timer, you would have to keep track of the start time and with each itteration check the current time to see how much time has passed. The loop is easy, working with datetime functions and the timespan object get a bit more involved though.

If you type in "StopWatch" into the help file, it has a nice downloadable example of a stopwatch type of program. It shows how you can compare and format elapsed time for display.

TomW 73 Posting Whiz

You sound like your trying to understand all that is going on with the code; so that is good. I didnt add comments to this to allow ya to think about it but if you need an explaination just ask.

Timer interval is set to 1,000

Personally I would do this with a loop, the StopWatch class and the TimeSpan object but I dont wanna get to far ahead of where your at in school.

Public Class Form1

    Dim m_intCounter As Integer = 0

    Private Sub btnStart_Click(...) Handles btnStart.Click

        If btnStart.Text = "Start" Then
            btnStart.Text = "Stop"
            m_intCounter = 0
            Timer1.Enabled = True
        Else
            btnStart.Text = "Start"
            lblTrafficLight.Text = ""
            lblTrafficLight.BackColor = Me.BackColor
            Timer1.Enabled = False
        End If

    End Sub

    Private Sub Timer1_Tick(...) Handles Timer1.Tick

        If m_intCounter >= 40 Then
            m_intCounter = 1
        Else
            m_intCounter += 1
        End If

        Select Case m_intCounter
            Case 1 To 20
                lblTrafficLight.Text = "Red"
                lblTrafficLight.BackColor = Color.Red
            Case 21 To 36
                lblTrafficLight.Text = "Green"
                lblTrafficLight.BackColor = Color.Green
            Case 37 To 40
                lblTrafficLight.Text = "Yellow"
                lblTrafficLight.BackColor = Color.Yellow
            Case Else
                'Do nothing
        End Select

    End Sub

End Class
TomW 73 Posting Whiz

Again I wouldnt use 3 different timers but if it is required by your class specifications, I added an example with using 3 different timers.

TomW 73 Posting Whiz
Private Sub btnStart_Click(...) Handles btnStart.Click

        If btnStart.Text = "Start" Then
            btnStart.Text = "Stop"
            lblTrafficLight.Text = "Red"
            timRed.Enabled = True
        Else
            btnStart.Text = "Start"

            Select Case True
                Case timRed.Enabled
                    timRed.Enabled = False
                Case timGreen.Enabled
                    timGreen.Enabled = False
                Case timYellow.Enabled
                    timYellow.Enabled = False
            End Select
        End If

    End Sub

    Private Sub timRed_Tick(...) Handles timRed.Tick
        lblTrafficLight.Text = "Green"
        timGreen.Enabled = True
        timRed.Enabled = False
    End Sub

    Private Sub timGreen_Tick(...) Handles timGreen.Tick
        lblTrafficLight.Text = "Yellow"
        timYellow.Enabled = True
        timGreen.Enabled = False
    End Sub

    Private Sub timYellow_Tick(...) Handles timYellow.Tick
        lblTrafficLight.Text = "Red"
        timRed.Enabled = True
        timYellow.Enabled = False
    End Sub
PcPro12 commented: helped me solve my problem completely, THANKS!!! :D +4
TomW 73 Posting Whiz

I think your confusing yourself with so many different timers. I would suggest only using one timer (interval to one second) and through coding keep track of the elapsed time and which light should be displayed. Also take a look at "StopWatch" in the help file it shows how to get, format & display elapsed time.

TomW 73 Posting Whiz

You can embed the wav files into your project by adding them to the project Resources.

TomW 73 Posting Whiz
Sub Main()

        Dim arrGrades(4) As Integer
        Dim intTotal As Integer = 0

        'Get input
        For intIndex = 0 To 4
            Console.Write("Enter the " & intIndex + 1 & " received grade: ")
            arrGrades(intIndex) = CInt(Console.ReadLine())
        Next

        Console.WriteLine()
        Console.WriteLine("######################################")
        Console.WriteLine()

        'Display Grades
        For intIndex = 0 To 4
            Console.WriteLine("Grade {0} : {1}", (intIndex + 1), arrGrades(intIndex).ToString)
            intTotal += arrGrades(intIndex)
        Next

        Console.WriteLine()
        Console.WriteLine("######################################")
        Console.WriteLine()

        Console.WriteLine("Average Grade : {0}", FormatNumber(intTotal / 5, 2))
        Console.WriteLine("Press Enter key to exit")

        Console.ReadLine()

    End Sub
TomW 73 Posting Whiz

Or in your project you can goto the properties window and click the checkbox that says "Make Single Instance application"

TomW 73 Posting Whiz

Seems like a silly question but did you actually create any tables within your dataset?

TomW 73 Posting Whiz

ahhh keyword, good catch...

As far as the missing data, make sure your not using two different versions of access, one that is your original and another that is just a copy of the original in your project.

TomW 73 Posting Whiz

Access gives weird error messages if you type the wrong column name. Move your query over to the MS Access designer and see if you can run it with the substituted parameter values as a test. I'm almost certain you get a syntax error instead of a "column does not exist" error in updates with access.

I'm kinda wondering about the error msg myself. Technically it shouldnt even know its an Update Statement, its not assigned to an update command of a data adapter.

TomW 73 Posting Whiz

Try taking out the conn.createcommand

Dim command As OleDbCommand = new oledbcommand
command.Connection = conn
TomW 73 Posting Whiz

Are you familar with Typed Datasets within your project? I add a dataset file to my project and create some tables within it to match the db tables & fields I want to work with in the database. Thats it.... (besides of course my coding to fill & work with the dataset but thats done elsewhere in my projects)

When you create a new report and the wizard dialog asks for a datasource, you will see that one of the options is for Ado.Net datasets, you can navigate directly to the dataset file within your project or point it to any dataset file (.xsd) file from any other project on your PC.

Your report will then have all the tables & fields available to you that are included in that dataset to work with although the dataset file itself is not directly connected to any info.