MYSQL 'LOAD DATA INFILE' Button onclick event RRS feed

  • Question

  • User-1621927083 posted

    I am having trouble using the MySql data connection to make a button onclick to run a query.

    So basically I am making an application to easily update our MySql database by having the user upload the txt file (Tab Delimited), and then once its uploaded they are redirected to another page (import.aspx) that has a button.

    When clicked this button is supposed to connect to the MySql database and implement the LOAD DATA INFILE statement to grab the file uploaded and use that as the source for the statement.

    I can't figure out how to connect to the database to do such a thing. I am using the connection method in the Web.Config file. basically, the statement would be something like:

    LOAD DATA INFILE 'Server.mappath("~/uploads/Update.txt")' into table test;                  when the button is clicked. Since it is a tab-delimited file, would this statement change.

    Any help would be appreciated.



    Wednesday, June 27, 2012 12:25 PM


  • User-1621927083 posted

    I wanted to reply to add the code I am working with:

    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
            Dim connection As MySqlConnection = New MySqlConnection(ConfigurationManager.ConnectionStrings("TestConnectionString").ConnectionString)
                Dim path As String
                path = Server.MapPath("~/uploads/Update.txt")
                'path = path.Replace("/", "//")
                Dim command As MySqlCommand = New MySqlCommand("LOAD DATA INFILE'" + path + "'into table names;", connection)
                'SAMPLE SQL: LOAD DATA INFILE 'c:/wamp/www/upload/Update.txt' into table names;
                If connection.State = ConnectionState.Open Then
                End If
            End Try
        End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 5, 2012 2:17 PM