您好我在查找错误和修复错误时遇到了问题,但是代码可以在DB中插入值
这将是我的代码,我怀疑它有错误
foreach (string Filename in filename_active)
{
string Spath_active = Filename.ToString();
string Dpath_active = Properties.Settings.Default.DestPath.ToString();
StreamReader active_Data_reader = new StreamReader(Spath_active);
active_num_lines = File.ReadLines(Spath_active.ToString()).Count();
string[] active_emp_data = new string[active_num_lines];
active_lines = active_num_lines * -1;
try// block of code that access the Active_emp.csv file
{
int i;
for (i = 0; i < active_num_lines; i++)// this block of code will cycle all of the row
{
active_emp_data = File.ReadAllLines(Spath_active.ToString());
for (int a = 0; a < active_emp_data.Length; a++)// this block of code will cycle all of the column
{
active_emp_data = active_Data_reader.ReadLine().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
My_addpt.SelectCommand = new SqlCommand("SELECT * FROM NGAC_USERINFO WHERE EmployeeNum =@EmployeeNum", conn);
My_addpt.SelectCommand.Parameters.Add("@EmployeeNum", SqlDbType.NVarChar).Value = active_emp_data[2].ToString();
conn.Open();
SqlDataReader My_reader;
My_reader = My_addpt.SelectCommand.ExecuteReader();
string man_num = active_emp_data[2].ToString();
bool z = false;
while (My_reader.Read())
{
if (My_reader["EmployeeNum"].ToString() == man_num.ToString())// this block of code will check is the data is present in the database
{
z = true;
}
}