Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have developed winform application in c# it was working fine in may development pc i have created installer package and deployed in another pc (Server 2008) part of the module is to get excel file display all records in a datagrid and was able to do all of these, get the excel file from a certain location,was able to logged in but when saving to the database it got an error(System.IO.Filenotfoundexeption).


Please help.
Posted

There's no way to tell you exactly what's wrong with your code because of the complete lack of detail on what your choice is supposed to be found at the time of the error and what that code looks like.

The meaning of the error is quite obvious. You tried to open a file someway and the file path you have doesn't exist.
 
Share this answer
 
Comments
JOEY G. MOYA 16-Dec-13 0:14am    
Yes, I Agree based on the error message but actully to give you more details, I was able to logged to the winform application which means i was able to connect to the database, i was able to open an excel file and was able to display to data gridview the records from an excel file which i was able to open the error came out when a button i clicked which contains saving of each row from grid data to the SQL SERVER

string InsertDetails = "INSERT INTO CycleDetails " +
"([postal] " +
",[province] " +
",[courier]" +
",[delivrydln]" +
",[MobileNo]" +
",[invno]" +
",[acctno]" +
",[soadte]" +
",[name]" +
",[billno]" +
",[tracerno]" +
",[clientID],[cycle],batchno,address,lname,fname)" +
"VALUES " +
"('" + GridForUpload.Rows[i].Cells[0].Value.ToString().Replace("'", "''") + "' " +
",'" + GridForUpload.Rows[i].Cells[1].Value + "'" +
",'" + GridForUpload.Rows[i].Cells[2].Value + "'" +
",'" + GridForUpload.Rows[i].Cells[3].Value + "'" +
",'" + GridForUpload.Rows[i].Cells[4].Value + "'" +
",'" + GridForUpload.Rows[i].Cells[5].Value + "'" +
",'" + GridForUpload.Rows[i].Cells[6].Value + "'" +
",'" + GridForUpload.Rows[i].Cells[7].Value + "'" +
",'" + namevaluefull + "'" +
",'" + GridForUpload.Rows[i].Cells[9].Value + "'" +
",'" + GridForUpload.Rows[i].Cells[10].Value + "','" + VarClientId + "','" + VarCycle + "','" + VarBatch + "','" + GridForUpload.Rows[i].Cells[11].Value.ToString().Replace("'", "''") + "','" + lastName + "','" + firstName + "')";

SqlCommand cmdsaveDtls = QuikConn.CreateCommand(InsertDetails);
qConect.Open();
cmdsaveDtls.Connection = qConect;
cmdsaveDtls.ExecuteNonQuery();
rowCount += 1;
qConect.Close();


this worked perfectly in my development pc but errors out when tried to execute in other pc
Dave Kreskowiak 16-Dec-13 0:31am    
The code you posted cannot possibly generate a "FileNotFound" exception unless the connection string specifies an attaching SQL file that cannot be found.
check your connection string...do you using dataset ??
 
Share this answer
 
Comments
JOEY G. MOYA 16-Dec-13 0:17am    
As mentioned i was able to logged to the application which means i was able to connect to the server. below is the actual code
qCon.Open();
cmd.Connection = qCon;
SqlDataAdapter dataAdapter = new SqlDataAdapter();
dataAdapter.SelectCommand = cmd;
DataSet dsResult = new DataSet("ResultSet");
dataAdapter.Fill(dsResult);
DataTable dtResult = dsResult.Tables[0];
int rowCount = 0;

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