Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I execute the following LOAD query of MYSQL, which works fine, when I use this query in MySql, but when I try to execute it through .Net it gives me error: Got Packets out of order error.

My Code:-
C#
try
{
    MySqlCommand cmdMySQL = conn.CreateCommand();
    if (conn.State == ConnectionState.Open)
        conn.Close();
    conn.ConnectionString = bs.constring;
    conn.Open();
    tran = conn.BeginTransaction();
    cmdMySQL.CommandText = @"LOAD DATA LOCAL INFILE 'C:\state1.txt' INTO TABLE state1 FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'";
    cmdMySQL.ExecuteNonQuery();
    tran.Commit();
}
catch (Exception ex)
{
    tran.Rollback();
    Label1.Text = "Data is not imported!! <br/>Error:" + ex.ToString();
}
finally
{
    conn.Close();
    conn.Dispose();
}


MySql Load Command is Correct, I have checked many times (and my C drive have that file & everything in that cmd is all right..)
Can any one tell me what can help me...
Or at least what this error means...
This command I have used with asp.net & it had worked fine...

Hi, Christian Graus.
Thanks for your reply.
Actually, I have a uplaodFile control through which you can uplaod CSV file containing required data, I save this file in my application and then copy this file to C Drive of user's computer who is using my application.
This all works fine...
In that there is no issue.
In short you can view command as:
C#
cmdMySQL.CommandText = @"LOAD DATA LOCAL INFILE 'C:\WebSite1\UploadData\state1.txt' INTO TABLE state1 FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'";

Where C:\WebSite1\UploadData\state1.txt path exists & state1.txt has my data.
This same command works fine in MYSQL, but not in ASP.Net (error: Got Packets out of order error)
Posted
Updated 10-Feb-10 6:04am
v7

How does the file get onto the root drive of your server ? I would expect when the user uploads it to the server, it would need to be stored under the application root.
 
Share this answer
 
Hi again. I deleted your duplicate question and also your fake 'answer' and edited your post to include your further comments, as it should be.

OK, so you're using the file on the server, and you're mapping to the file path correctly inside your web application. I can only assume that the error has to do with running inside a web app. Perhaps if you edit your post to give us the ACTUAL error message and stack trace ?

You might also want to look here[^].
 
Share this answer
 
v2
Hi,Christian Graus.
Im new to code project..
And i dnt know how to re-question to the person who have posted me answer to my question thats why i submit it as answer.
Can u tell me how to do this.

And thanks 4 that reference..
im checking it,to get my answer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900