1
我尝试比较下一个位置fecmov当前位置,但没有工作,他们总是不同的,虽然他们不是验证比较两行用C#OleDbDataReader擅长
我有这样的代码:
string FECMOV;
string filePath = Path.GetDirectoryName(FileUploader.PostedFile.FileName);
if (Path.GetExtension(filePath) == ".xls") {
con1 = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1;TypeGuessRows=0;ImportMixedTypes=Text;MaxScanRows=0\"", filePath);
}
else if (Path.GetExtension(filePath) == ".xlsx") {
con1 = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=Yes;IMEX=1;TypeGuessRows=0;ImportMixedTypes=Text;MaxScanRows=0\"", filePath);
}
using (OleDbConnection connect = new System.Data.OleDb.OleDbConnection(con1)) {
connect.Open();
OleDbCommand command = new System.Data.OleDb.OleDbCommand("select * from [Sheet1$]", connect);
using (OleDbDataReader dr = command.ExecuteReader()) {
if (dr.HasRows) {
while (dr.Read()) {
if (dr.IsDBNull(4)) {
FECMOV = "";
}
else {
FECMOV = dr[4].ToString().Trim();
}
//this validation I try to compare
// the current position with the next
//position fecmov, but not working,
if (FECMOV[a] != FECMOV[a + 1])
{
a=a+1
}
//They are always different though they are not validate
}}}
FECMOV是一个字符串,您所在的位置'了'与字符的位置'A + 1'比较字符。你期望你的字符串一直由同一个字符组成吗? – Steve
是的,我需要比较第一个寄存器与同一列的第二个寄存器... – YotiS