protected void btnCSV_Click(object sender, EventArgs e) { string filePath = "D:\\users3.txt"; string line; //if (File.Exists(filePath)) //{ StreamReader file = null; try { file = new StreamReader(filePath); //LOCAL while ((line = file.ReadLine()) != null) { string Firstname = line.Split(',')[0]; string Lastname = line.Split(',')[1]; string Date = line.Split(',')[2]; string ActiveCode = "A"; DataSet dsInsert = new DataSet(); SqlDataAdapter daInsert = new SqlDataAdapter("EXECUTE usersInsert '" + Firstname + "','" + Lastname + "','" + Date + "','" + ActiveCode + "'", System.Configuration.ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString); daInsert.Fill(dsInsert); lblFuDocInAB.Text = "Successfully added new user!"; //lblFuDocInAB.Text = daInsert.SelectCommand.CommandText.ToString(); } } catch (Exception ex) { if (file != null) file.Close(); lblFuDocInAB.Text = ex.Message.ToString(); } System.IO.File.Delete(Request.PhysicalApplicationPath + filePath); //} }
I successfull added users in my db,but get Index was outside the bounds of the array. C#
any solution?