mrbungle 29 Junior Poster in Training

OMG. I can't believe it. Yes, I have it "installed" but I neglected to put in the product key and run it. I can't believe the stupidity.

Thanks.... feel dumb now.

mrbungle 29 Junior Poster in Training

SYSTEM: Windows 8.1 Tablet, VS 2012

OLD SYSTEM: Windows 7, VS 2013 Enterprise (thanks to my employer)

Something is wrong. I never had any errors on my old system. On my new system, I'm getting the following:

An unhandled exception of type 'System.Exception' occurred in Microsoft.VisualBasic.dll
Additional information: Cannot create ActiveX component.

So I'm not sure why it can't create the ActiveX component. I'm trying to open Word to create a file. The error appears at the oWord = CreateObject("Word.Application"). Here is some code:

Imports System.IO
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Word

Public Class clsPrint

#Region "====================== PRINT REPORT COVER SHEET ======================"

    Public Sub printFrmReportCoverSheet()

        Dim oWord As Word.Application
        Dim oDoc As Word.Document

        oWord = CreateObject("Word.Application")
        oWord.Visible = True
        oDoc = oWord.Documents.Add(x.myReportCoverSheetFormWordFile)

        frmProgressBar.Text = "Your report is being built.."
        frmProgressBar.ProgressBar1.Increment(25)

        oDoc.Bookmarks.Item("case").Range.Text = frmReportCoverSheet.txtCase.Text
        oDoc.Bookmarks.Item("datetime").Range.Text = frmReportCoverSheet.txtDateTime.Text

 ------ AND SO ON-------

        oWord.PrintPreview = True ' print preview mode
        oWord = Nothing
        oDoc = Nothing

    End Sub

#End Region

End Class

For my references, I'm using:

Interop.Microsoft.Office.Interop.Word
Interop.Microsoft.Office.Core
Interop.Microsoft.Office.Core

Any ideas?

Do I need my app to create an ActiveX.dll and include it?

Thanks

mrbungle 29 Junior Poster in Training

I'me going to mark this as solved, and try a different installer. Thanks everyone for your time and help.

mrbungle 29 Junior Poster in Training

Thanks, I never considered building my own installer.

mrbungle 29 Junior Poster in Training

Thanks for the reply. This error I posted happens upon the actual install, before the program even gets to launch. Something tells me this might me a problem with the installer program I'm using.

To answer your questions, I've tested on both 32 and 64- one agency is all on 64 bit laptops and they don't have any problems. It's targeted for AnyCPU. I set it for x64 and it wouldn't run on my 32 bit machine. The .NET is the client version.

Sorry about the uninstaller. Looks like I should look around for a new installer app.

mrbungle 29 Junior Poster in Training

I have a quick question- I have an app that is downloaded a lot and used lots without issues. Recently an officer from the US Forest Service downloaded it, and when he tries to install, he's getting this message box-

c5cb2b8f701441a47757e657cd5e89b1

I don't believe this is a problem with my app, but I want to make sure. He has installed it on two fresh/new Panasonic CF-31's with Win7, so the laptops are new. He has .Net4 installed as needed. The app is compiled by a program I use from http://www.installsimple.com/.

I've searched the internet for that specific error, but I'm not really getting anywhere. While I am leaning towards this being a problem with his machine, he said he tried on two new machines with the same error.

I could also be leaning towards (if it is app related) the problem being with the compiler perhaps?

The app itself is located here- https://dl.dropboxusercontent.com/u/31131259/DailyLog%20Basic/Setup%20Basic.exe

I'm at a loss because I've done code tests and I'm not getting any errors.

Does anyone have any ideas?

mrbungle 29 Junior Poster in Training

Sorry, got busy with life, forgot to thank everyone for their replies and code. Mucho gracias!

mrbungle 29 Junior Poster in Training

In my app, I have a text box that takes the text and transfers it to w Word doc for printing. It does this with the bookmark feature in Word.

On the Word doc, I only have "X" amount of space. The bookmark in Word will auto size and fill with as much text as I want, but I need to limit this, and only have (for example) up to 900 characters in that specific bookmark. The remainder of the text I need to go to a seperate sheet.

Here is the (stripped down) code I use to transfer the text to the Word doc as an illistration:

Public Sub printPC_Affidavit()

        Dim oWord As Word.Application
        Dim oDoc As Word.Document
        oWord = CreateObject("Word.Application")
        oWord.Visible = True
        oDoc = oWord.Documents.Add(x.myPC_AffidavitDOTFile)

        oDoc.Bookmarks.Item("txtOffense1").Range.Text = frmPC_Affidavit.txtOffense1.Text
        oDoc.Bookmarks.Item("txtOffense2").Range.Text = frmPC_Affidavit.txtOffense2.Text

        oDoc.Bookmarks.Item("txtPC").Range.Text = frmPC_Affidavit.txtPC.Text

        oWord.PrintPreview = True ' print preview mode
        oWord = Nothing
        oDoc = Nothing
        GC.Collect()

    End Sub

So the bookmark in Word is called txtPC. I'll have to create another template in Word, and in it create another bookmark (that I'll call) txtPC2 or something.

So how do I get any characters over the 900 over to the second template?

mrbungle 29 Junior Poster in Training

Perfect- thanks.

mrbungle 29 Junior Poster in Training

Let me add more information- two text fields in the app- txtCiteStart.Text and txtCiteEnd.Text. In the DB, two columns- citestart and citeend. No problems adding those two sets of numbers to the DB. Not sure where to go from there... :(

mrbungle 29 Junior Poster in Training

Yeah, that sounds good, and I thought of that. Does anyone have some sample code they could provide to cycle through the numbers? I'm not sure where to start.

mrbungle 29 Junior Poster in Training

I'm not sure how to tackle this problem. I have an app that has a range of numbers, like D100100 to D100200. Right now, it's all done with a text file, and what needs to happen is each document needs it's own number in sequence. They are DUI Citations. So, each citation needs it's own citation number. And right now, everything works fine- sort of.

The data from the citations are saved to MySQL. An officer can open the program, and either create a new citation (that needs it's own number next in the sequence) or open a previous citation from a case number (in case they need to make a correction and re-print the citation).

If you enter a case number and pull in an older citation thats in the database, it also pulls in the citation number- which is needed. Everything is fine there.

But when the citation that was pulled in is closed, my app currently takes it's citation number and saves it.

If you were currently on citation #100 for example, you would bring it (the citation form) up and it would advance to 101. BUT, when you wanted to go back and look at an old citation- say #75, then closed the program, the next time you opened it, it would open on citation #76, NOT #101 like it should. Thats bad.

So I'm wondering if cycling through these numbers in MySQL would be a better solution than using a text file. My logic is …

mrbungle 29 Junior Poster in Training

kingsonprisonic, Reverend Jim and everyone else-

Thank you. You all jogged my thought process enough to get it to work. Here's what I did.

On Form Load, it calls x.CreateIDfolder()

In my x.module, I have this peice of code.

Public Sub CreateIDfolder()
        ' Create the officers folder based on his ID number
        If Not Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\DailyLog\Files\" & "" & frmMain.lblID.Text & "") Then
            Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\DailyLog\Files\" & "" & frmMain.lblID.Text & "")
        End If
        ' Move current files into the new folder- the log files based on year.
    End Sub

This sucessfully created the folder, basedon the login ID number, and puts it in the right folder.

I think I might have been getting overly complicated in my earlier approach.

Thank you for all you help, time and patience.

Rob

mrbungle 29 Junior Poster in Training

No silly questions, they don't exist :)

There is a login form that loads first. Once that authenticates, the frmMain loads. When frmMain loads, it's pulling the info from the DB.

I agree with you on creating the folder following a successful log in. As mentioned, I tried to test this by a button that created the folder. Once everything loaded, and I could see the label with the ID number in it, I tried creating the folder by clicking the button. It created, but it wasn't the ID number, it was the lblID, the default text of the label.

I'm trying to put my finger on this problem. I thought it was an issue with the order everything was loading, but using the button to create the folder to test it still didn't work.

The X is just the name of the module. It's simple. It doesn't signify anything. I keep a lot of code in there, such as:

Public myFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\DailyLog\" '  Main Directory in Program Files"
    Public myAppDataFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\DailyLog\" '  Main Directory in App Data

    ' ------------- CRITICAL Folder FILES
    Public myCriticalFolder As String = myAppDataFolder & "Critical\"
    Public myBackupFile As String = myCriticalFolder & "Backup File.txt" '  File to save as Backup.
    Public myDetailsFile As String = myCriticalFolder & "Details.txt" '  Details file- area, department, officer, etc.
    Public myLocationsAndCallTypesFile As String = myCriticalFolder & "Locations and Call Types.txt" ' -- File …
mrbungle 29 Junior Poster in Training

K, starts out here (stripped all the useless code not needed)

Public Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' Create the new folder on officer ID for the new multi user app
        x.CreateIDfolder()

    End Sub

x.vb is a module that contains a ton of variables.

This is in x.vb

Public Sub CreateIDfolder()
        ' Create the officers folder based on his ID number
        ' This is for the new version, a new multi-user application.
        If Not Directory.Exists(myOfficerIDFolder) Then
            Directory.CreateDirectory(myOfficerIDFolder)
        End If
        ' Move current files into the new folder- the log files based on year.
    End Sub

Also in x.vb, is the myOfficerIDFolder part.

Public myFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\DailyLog\" '  Main Directory in Program Files"
    Public myAppDataFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\DailyLog\" '  Main Directory in App Data

 ' ------------- FILES Folder FILES
    Public myFilesFolder As String = myAppDataFolder & "Files\"
    Public myOfficerIDFolder As String = myFilesFolder & "" & frmMain.lblID.Text & ""

So, in short, the file based on the ID is inside the Files folder in the application data.

mrbungle 29 Junior Poster in Training

Thanks- tried that. I put the x.CreateIDfolder() on a button and called it well after the DB variables loaded. Didn't work. Is that what you mean?

mrbungle 29 Junior Poster in Training

Yes, it's in frmLoad.

mrbungle 29 Junior Poster in Training
Public Sub CreateIDfolder()
        ' Create the officers folder based on his ID number
        ' This is for the new version, a new multi-user application.
        If Not Directory.Exists(myOfficerIDFolder) Then
            Directory.CreateDirectory(myOfficerIDFolder)
        End If
        ' Move current files into the new folder- the log files based on year.
    End Sub

I was wondering if it was an issue with the order these things were loading. So I put the CreateIDfolder on a button, and clicked it long after the label populated with the ID number. It didn't matter. It created a folder called lblID.

mrbungle 29 Junior Poster in Training

I've been at this for a few days, not making any progress, so I'm asking for help.

I have an application you log into based on an ID number (example 45)

In the app, there is a label. By default is has "lblID" in it, when when you log in, the 45 goes there (comes from MySQL)

I need to create a new folder on startup, and that folder needs to be named according to that ID number.

The problem I'm running into , is when the application starts, it creates the folder just fine, but it never names it according to the ID. It always names it lblID.

The code to create the folder is in the frmLoad-

x.CreateIDfolder()

Then it goes to the code in a module-

Public Sub CreateIDfolder()
        ' Create the officers folder based on his ID number
        ' This is for the new version, a new multi-user application.
        If Not Directory.Exists(myOfficerIDFolder) Then
            Directory.CreateDirectory(myOfficerIDFolder)
        End If
        ' Move current files into the new folder- the log files based on year.
    End Sub

Then in the same module, it creates the name from the ID number (or so it should)

Public myFilesFolder As String = myAppDataFolder & "Files\"
    Public myOfficerIDFolder As String = myFilesFolder & "" & frmMain.lblID.Text & ""

So as I mentioned, the folder is always lblID. Where am I going wrong?

mrbungle 29 Junior Poster in Training

Thanks for your help everyone. I got busy a couple of days but got back to work on it today.

Thanks again.

mrbungle 29 Junior Poster in Training

UPDATE- it all works fine. Do I really have to shut the app down and restart it to get the values to work in My.Settings? I have

' Save IP and port to MySettings FIRST THING
        With My.Settings
            .ServerIP = txtServerIP.Text
            .ServerPort = txtServerPort.Text
            .Save()
        End With

on Public Sub OK_Click as the very first thing to do. I thought it would save the value, then at the end of the sub it calls the

Dim load As New clsMySQL
        load.Login()

to load the string from

Public urlMySQLDatabase1 As String = _
      "Server=" & My.Settings.ServerIP & ";" _
    & "Port=" & My.Settings.ServerPort & ";" _
    & "Database=" & "Database" & ";" _
    & "Uid=" & "UserID" & ";" _
    & "Pwd=" & "Password" & ";"

When I click OK it saves, but only on the next startup of the application.

mrbungle 29 Junior Poster in Training

Thanks for the replies. Yes, the values are being saved in a config file. I was thinking that I would just use the config file to write to and save the values to. But, from your suggestions, I'll use MySettings instead. I'm having to many problems with the config file.

I'll post the code when I'm done.

mrbungle 29 Junior Poster in Training

1: Form loads:

Public Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        x.loadSettingsAndDataFile()

    End Sub

2: Next, it loads the x.loadSettingsAndDataFile() that puts the server and port into the text boxes on the frmLogin:

Public Sub loadSettingsAndDataFile()
        If File.Exists(mySettingsAndDataFile) Then
            Dim arFileLines() As String = IO.File.ReadAllLines(mySettingsAndDataFile)
            For i As Integer = 0 To arFileLines.Length - 1
                Try
                    With arFileLines(i)

                        ' ================= GLOBAL OPTIONS =================\\


                        For Each line As String In arFileLines
                            ' With frmMain
                            With frmLogin
                                'If line.StartsWith("Mileage =") Then .txtStartMiles.Text = line.Substring(line.IndexOf("=") + 2)
                                If line.StartsWith("Login ID = ") Then .txtUserID.Text = line.Substring(line.IndexOf("=") + 2)
                                If line.StartsWith("Password = ") Then .txtUserPassword.Text = line.Substring(line.IndexOf("=") + 2)
                                If line.StartsWith("ServerIP = ") Then .txtServerIP.Text = line.Substring(line.IndexOf("=") + 2)
                                If line.StartsWith("ServerPort = ") Then .txtServerPort.Text = line.Substring(line.IndexOf("=") + 2)
                            End With
                            'With frmServerIP
                            '    If line.StartsWith("ServerIP = ") Then .txtServerIP.Text = line.Substring(line.IndexOf("=") + 2)
                            'End With
                        Next

                    End With
                Catch ex As Exception
                    MsgBox("Error loading: " & mySettingsAndDataFile & vbNewLine & "Error #30", MsgBoxStyle.Critical)
                End Try
            Next
        End If
    End Sub

3: Now that the text boxes are populated, when the user clicks OK, it loads the MySQL section which included the string:

Public urlMySQLDatabase1 As String = _
      "Server=" & frmLogin.txtServerIP.Text & ";" _
    & "Port=" & frmLogin.txtServerPort.Text & ";" _
    & "Database=" & "dailylogmain" & ";" _
    & "Uid=" & "dailylogmain" & ";" _
    & "Pwd=" & "Dailylog2011" & ";"

It goes out to the MySQL, validates the user, etc. But before it can get …

mrbungle 29 Junior Poster in Training
Public urlMySQLDatabase1 As String = _
    "Server=" & frmLogin.txtServerIP.Text & ";" _
& "Port=" & frmLogin.txtServerPort.Text & ";" _
& "Database=" & "Database" & ";" _
& "Uid=" & "UserID" & ";" _
& "Pwd=" & "Password" & ";"

Gives the first message box.

Public urlMySQLDatabase1 As String = _
  "Server=" & "173.201.80.90" & ";" _
& "Port=" & "3300" & ";" _
& "Database=" & "Database" & ";" _
& "Uid=" & "UserID" & ";" _
& "Pwd=" & "Password" & ";"

Gives the second message box with the IP and port

mrbungle 29 Junior Poster in Training

Ok, here is a messagebox with what the error is giving me. The line it is referring to (line 43) is MySqlConnection.Open()- Unable to conenct to any specified hosts.

With this connection string, I am able to connect-

Public urlMySQLDatabase1 As String = _
  "Server=" & "173.201.80.90" & ";" _
& "Port=" & "3300" & ";" _
& "Database=" & "Database" & ";" _
& "Uid=" & "UserID" & ";" _
& "Pwd=" & "Password" & ";"

This one does not.

Public urlMySQLDatabase1 As String = _
    "Server=" & frmLogin.txtServerIP.Text & ";" _
& "Port=" & frmLogin.txtServerPort.Text & ";" _
& "Database=" & "Database" & ";" _
& "Uid=" & "UserID" & ";" _
& "Pwd=" & "Password" & ";"

I hope this information helps.

mrbungle 29 Junior Poster in Training

Thanks Reverend- great suggestion.

Both strings work, when I hard code the IP and port. I'm finding that the problem is the frmLogin.txtServerIP.Text part- it doesn't want to pick up the values from the textbox.

I'll keep working on this and try to figure out what the deal is.

mrbungle 29 Junior Poster in Training

Thanks for your quick reply Smith- I tried it and it's still unable to connect. Your suggestion made sense to me though.

The error is:

Unable to connect to any of the specified MySQL hosts.

mrbungle 29 Junior Poster in Training

I have a hard coded connection string that DOES work just fine-

Public urlMySQLDatabase1 As String = "Server=170.200.80.90;port=3300;Database=DatabaseName;Uid=UserID;Pwd=Password;"

However, I want the server and port to be dependent on the values in a textbox. I thought something like this would work but it won't connect-

Public urlMySQLDatabase1 As String = "Server=" & frmLogin.txtServerIP.Text & ";" _
        & "Port=" & frmLogin.txtServerPort.Text & ";" _
        & "Database=DatabaseName"";" _
        & "Uid=UserID"";" _
        & "Pwd=Password"";"

Does anyone have any suggestions for me?

mrbungle 29 Junior Poster in Training

Thanks for taking the time to reply hericles. For some reason I forgot about the config settings.

mrbungle 29 Junior Poster in Training

My app is using MySQL. Right now, the IP/Port, username and all that stuff is hard coded in a string.

Public urlMySQLDatabase1 As String = "Server=173.201.88.22;port=3306;Database=DBName;Uid=DBName;Pwd=DBpassword;"

So all the code that needs this string gets it here.

But I was thinking- what if later in the future I need to change this- I could send out an email to the users to open a form I created and they could change the IP. So I created a form, and I can write this IP to an .ini file my app uses to hold some other data.

When the app pulls anything from the .ini file, it calls the loadSettingsFile()

Public Sub loadSettingsFile()
        If File.Exists(mySettingsFile) Then
            Dim arFileLines() As String = IO.File.ReadAllLines(mySettingsFile)
            For Each line As String In arFileLines
                With frmLogin
                    If line.StartsWith("Login ID = ") Then .txtUserID.Text = line.Substring(line.IndexOf("=") + 2)
                    If line.StartsWith("Password = ") Then .txtUserPassword.Text = line.Substring(line.IndexOf("=") + 2)
                End With
                With frmServerIP
                    If line.StartsWith("ServerIP = ") Then .txtServerIP.Text = line.Substring(line.IndexOf("=") + 2)
                End With
            Next
        End If
    End Sub

So my question is- how can I write that string above (urlMySQLDatabase1) to use the IP that's written in the .ini file and not always hard coded? I can't seem to wrap my head around this.

TIA

mrbungle 29 Junior Poster in Training

Yup, that worked. I see how you did that- thanks!

mrbungle 29 Junior Poster in Training

I have a listview that pulls data from a MySQL and I can now finally sort queries by date range (thanks Unhnd Exception!!). Also in that query, I have it sorted by ID number.

This brings me to another question. The ReportViewer pulls up a really nice report for my users with this data. Now I can sort it by:

1: User ID Number (officer_id in MySQL) OR
2: Date range (startdate and enddate in MySQL)

So here's what I have so far.

I can use the following filters to sort my query by officer ID number in the ReportViewer-

'Filtering the DataGrid to display only the rows of the selected Officer ID given in the main form textbox.text
        TrainingBindingSource.Filter = "Officer_ID LIKE '%" & frmMain.lblID.Text & "%'"

Then, I figured out how to sort and display my query in the report viewer with this statement-

TrainingBindingSource.Filter = String.Format _
        ("startdate >= #{0:MMM/dd/yyyy}# And enddate <= #{1:MMM/dd/yyyy}#", frmMain.dtpTrainingStart.Text, frmMain.dtpTrainingEnd.Text)

The first code works well sorting by the oficers ID number, and the second one works well sorting by date.

But how do I combine the both of them? As it is, they don't work as separate filters. I guess they need to be all meshed together?

mrbungle 29 Junior Poster in Training

Absoultly brilliant! You solution worked exactly as needed.

The suggestion to "You may just need to change your = sign to >= startdate and <= enddate" is what it took. Here is the working statement-

Dim sqlQuery As String = "SELECT * FROM Training WHERE Training.startdate >=  '" & frmMain.dtpTrainingStart.Text.ToString & "' AND Training.enddate <= '" & frmMain.dtpTrainingEnd.Text.ToString & "'"

Thanks everyone for their time!

mrbungle 29 Junior Poster in Training

My intention is to pick any records that fall within (anything in between) the start date and end date, not specifically EQUAL to the two dates.

As for validation, you are correct. That will be my second hurdle to get over. I'll probably ask about that later.

mrbungle 29 Junior Poster in Training

Thanks- I just tried it and while it refreshes, the selected date range isn't coming through.

mrbungle 29 Junior Poster in Training

Hey,

I need to pick from two date ranges from a couple of datetimepickers in the form. Then when I run the query, it should clear the current data in the listview, run the query, then re-populate the listview.

I use the same code to simply load the listview, and similar code to delete from the MySQL and reload the listview and everything works great. But this one isn't working- it doesn't generate any errors, but also doesn't sort either.

Can someone take a look and double check it for me? I suspect something is wrong.

Public Sub SortByDateTraining()

        MySqlConnection.ConnectionString = x.urlMySQLDatabase1
        Try
            MySqlConnection.Open()
        Catch ex As Exception
            MsgBox("It looks like your internet is taking a second to pull the required data... ")
        End Try

        ' Clear the items in the listview to reload them from the query below
        frmMain.lvTraining.Items.Clear()

        Dim sqlQuery As String = "SELECT * FROM Training WHERE Training.startdate =  '" & frmMain.dtpTrainingStart.Text & "' AND Training.enddate = '" & frmMain.dtpTrainingEnd.Text & "'"

        Dim sqlAdapter As New MySqlDataAdapter
        Dim sqlCommand As New MySqlCommand
        Dim TABLE As New DataTable

        With sqlCommand
            .CommandText = sqlQuery
            .Connection = MySqlConnection
        End With

        With sqlAdapter
            .SelectCommand = sqlCommand
            .Fill(TABLE)
        End With

        For i = 0 To TABLE.Rows.Count - 1
            With frmMain.lvTraining
                .Items.Add(TABLE.Rows(i)("number"))
                With .Items(.Items.Count - 1).SubItems
                    .Add(TABLE.Rows(i)("startdate"))
                    .Add(TABLE.Rows(i)("enddate"))
                    .Add(TABLE.Rows(i)("location"))
                    .Add(TABLE.Rows(i)("traininghours"))
                    .Add(TABLE.Rows(i)("trainingtype"))
                    .Add(TABLE.Rows(i)("trainingname"))
                    .Add(TABLE.Rows(i)("certification"))
                    .Add(TABLE.Rows(i)("expiration"))
                End With

            End With
        Next
        CalculateTrainingHours()
        MySqlConnection.Close()

    End Sub
mrbungle 29 Junior Poster in Training

Good suggestion- that's what I'll do. Thanks.

mrbungle 29 Junior Poster in Training

As the title says- I'm not sure which appdata folder to use-

Should I use CommonApplicationData, The directory that serves as a common repository for application-specific data that is used by all users.

Or

LocalApplicationData, The directory that serves as a common repository for application-specific data that is used by the current, non-roaming user.

Is there any pro's or cons to each one? My app typically won't be used on a computer that is accessed by more than one user. The typical use is each user has their own laptop.

Is there any opinions or schools of thought on this?

I want to get this right the first time, because I don't want to have to make changes down the road.

Thanks

mrbungle 29 Junior Poster in Training

Code- perfect example- thanks!

mrbungle 29 Junior Poster in Training

progress-

This helped-

Dim load As New clsFTP
        Thread = New System.Threading.Thread(AddressOf load.UploadLogsWithFTP)
        Thread.Start()
mrbungle 29 Junior Poster in Training

I'm having a hard time understanding this.

I get what multithreading is- allowing a program to run more than one thread to improve performance, by splitting up some of it's resources.

So I'm at the point in my app where I need to use it. I need to upload some small text files in the background while the app is running and the user won't know their stuff is being backed up via FTP.

I don't understand where to put start- I have some code I found and a couple of good tutorials explaining the process- but...

Where do I put it? For example- I have a main form. I have a button that calls a class, and in the class is FTP code to upload some small text files. So what gets the separate thread? The class? The main form? I don't get it.

Here's some code- I don't think I have this right-

Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click

        Dim load As New clsFTP
        load.UploadLogsWithFTP()
        Thread = New System.Threading.Thread(AddressOf load.UploadLogsWithFTP)
        Thread.Start()

    End Sub

Then more code in clsFTP (this isn't all the code)

Then I can't use Imports System.Threading in my main form 'cause it screws with my timers...

I dunno, I'm not getting this..

mrbungle 29 Junior Poster in Training

While I'm here, here's the code I used to update my column in my database. This is it's most basic form without the message boxes and stuff.

Public Sub SaveOfficerInfo()

        MySqlConnection.ConnectionString = x.urlMySQLDatabase
        Dim myCommand As New MySqlCommand
        Dim MyAdapter As New MySqlDataAdapter
        Dim SQL As String
        MySqlConnection.Open()
        myCommand.Connection = MySqlConnection
        MyAdapter.SelectCommand = myCommand
        SQL = "UPDATE Users SET area = '" & frmOptions.txtAddArea.Text & "' WHERE officer_id = '" & frmOptions.txtAddID.Text & "'"
        myCommand.CommandText = SQL
        myCommand.ExecuteNonQuery()
        SQL = "UPDATE Users SET supervisor = '" & frmOptions.txtAddSupervisor.Text & "' WHERE officer_id = '" & frmOptions.txtAddID.Text & "'"
        myCommand.CommandText = SQL
        myCommand.ExecuteNonQuery()
        MySqlConnection.Close()


    End Sub

Thanks again everyone for your help.I appreciate it.

mrbungle 29 Junior Poster in Training

Thanks everyone for your patience in dealing with me- I know it can be hard. The W3 page helped a lot, I got it figured out what I need and got my value to update. It's hard sometimes trying to filter through all the information on the net, it seems like there's always 5 different ways to do one task.

mrbungle 29 Junior Poster in Training

Anyone see any problems here?

MySqlCommand.Connection = MySqlConnection
        MySqlDataAdapter = New MySqlDataAdapter _
        ("UPDATE INTO Users SET (officer_id, area, supervisor) VALUES ('" & frmOptions.txtAddID.Text & "','" & frmOptions.txtAddArea.Text & ",'" & frmOptions.txtAddSupervisor.Text & "')", MySqlConnection)


        MySqlCommand.Parameters.AddWithValue("officer_id", frmOptions.txtAddID.Text)
        MySqlCommand.Parameters.AddWithValue("area", frmOptions.txtAddArea.Text)
        MySqlCommand.Parameters.AddWithValue("supervisor", frmOptions.txtAddSupervisor.Text)
        'MsgBox("Information Saved. ")
        Try
            MySqlCommand.ExecuteNonQuery()
mrbungle 29 Junior Poster in Training

Crap, I just realized something- I'm using the WRONG COMMAND! I need an UPDATE statement... :( There is already a value in the column, so I need to overright it.

mrbungle 29 Junior Poster in Training

Thanks for the reply Adam- my data isn't saving so let me use a similar example- it looks right to my uneducated eye. The table is Users.

MySqlCommand.Connection = MySqlConnection
        MySqlDataAdapter = New MySqlDataAdapter _
        ("INSERT INTO Users (officer_id, area, supervisor) VALUES ('" & frmOptions.txtAddOfficer.Text & "','" & frmOptions.txtAddArea.Text & ",'" & frmOptions.txtAddSupervisor.Text & "')", MySqlConnection)

        MySqlCommand.Parameters.AddWithValue("officer_id", frmOptions.txtAddOfficer.Text)
        MySqlCommand.Parameters.AddWithValue("area", frmOptions.txtAddArea.Text)
        MySqlCommand.Parameters.AddWithValue("supervisor", frmOptions.txtAddSupervisor.Text)
        MsgBox("Information Saved. ")
        Try
            MySqlCommand.ExecuteNonQuery()

Are these commands ultra finicky- like even if there's a space in there somewhere it won't work? When I run the app, it's error and warning free.

mrbungle 29 Junior Poster in Training

Quick question...

Say I have a login form with a user ID, then a text box on the main form.

When the main form closes, it takes that value from the text box and inserts it into the column based on that users ID

Here's my code-

'// Save mileage to DB
                MySqlConnection.ConnectionString = x.urlMySQLDatabase
                Try
                    MySqlConnection.Open()
                Catch ex As Exception
                    MsgBox("It looks like your internet is taking a second to get squared away... ")
                End Try
                MySqlCommand.Connection = MySqlConnection
                MySqlDataAdapter = New MySqlDataAdapter _
                ("INSERT INTO Users.id =  " & lblID.Text & " mileage VALUES ?" & txtEndMiles.Text & ";", MySqlConnection)
                MySqlCommand.Parameters.AddWithValue("?mileage", txtEndMiles.Text)

                Try
                    MySqlCommand.ExecuteNonQuery()
                Catch ex As Exception
                    ' no error message yet- pending
                Finally
                    MySqlConnection.Close()
                End Try
                '// End save mileage to DB

So I guess my question is, can some take a look at my INSERT statement for me?

Each row in the database has an id column and mileage column.

lblID.Text is the users ID number, it shows on the main form, so I figured I could use that value,
txtEndMiles.Text is the text box on the main form.
mileage is the column in the database to store that value.

("INSERT INTO Users.id =  " & lblID.Text & " mileage VALUES ?" & txtEndMiles.Text & ";", MySqlConnection)
                MySqlCommand.Parameters.AddWithValue("?mileage", txtEndMiles.Text)
mrbungle 29 Junior Poster in Training

Yea, exactly- I'm using an ID because it's always unique, unlike name.

I'm troubleshooting the connection now- it keeps failing to connect.

Connection issue resolved. Checking the database, my data isn't being put in there.

So I have one table called users. In that table, when I click on Structures, I have my rows of stuff I need to collect. So in those rows, I have stat1, stat2, stat3, etc. because in the app, I have some text boxes labeled txtStat1, txtStat2, and so on to 14.

Now, I'm learning and figuring out the best way to lay out my database. I'll have 5 or 6 users that use this app, and each one has their own ID number. So when they log into the app, they need their ID number and password before they get in, which is stored in the users table under each person (just me so far). And so far, I have the login working fine. And in the app there is a field for their ID, called txtAddID, and other stuff like name, address, supervisor, area, phone, etc.

Later on, I'll learn and figure out that part where the app calls the data from the database to populate the text boxes when the app runs. But in phase 1, I'm working on using the app to get the data into the database.

mrbungle 29 Junior Poster in Training

Do you mean update data with the ID for criteria ?

Yea, exactly- I'm using an ID because it's always unique, unlike name.

I'm troubleshooting the connection now- it keeps failing to connect.

mrbungle 29 Junior Poster in Training

Thanks- I forgot the Handles. I got some activity, but it just closed the form- my confirmation message box didn't appear.

I still can't figure out this part either- I don't think my data is being put where it needs to. How do I add the data from the text box to a column based on an ID in a users table?

Dim SQLStatement As String = "INSERT INTO users(stat1) VALUES('" & Me.txtStat1.Text & "')"