strSqlNewFlag = "update SendingMmsTable set NewFlag=" + countNewFlag + "where MMSindex =" + Mms_ID;
其中countNewFlag 已经等于2了,可是却发现strSqlNewFlag 还是"update SendingMmsTable set NewFlag=1where MMSindex =6,其中1是我初始化变量的时候赋的
为什么呀,好像给字符串引用赋值失败了???
public int GetMms(SerialPort comm, int Mms_ID)
{
int state = 0, intRe = 0;
int countNewFlag = 1;
int count = 0;
String strSql, strPhone = "", /*strNote = "",*/strTitle ="",/*strAttachment ="" ,*/ mmsMode ="",strSqlNewFlag="";
DataTable dTable;
try
{
//遍历表的每列并将文本文字和附件的地址分别放到数组中,以便于使用
strSql = "Select Top 1 * From SendingMmsTable Where MmsIndex=" + Mms_ID;
dTable = this.SelectDataBase(strSql);
ArrayList arrayStrNote = new ArrayList();
......
mmsMode = dtRow["MMSMode"].ToString(); strSql = "Insert Into SentMmsTable(PhoneNumber,ChaoSongNumber,AnSongNumber,MmsTime,MmsUser,Status,MmsTitle,MMSContent0,MMSContent1,MMSContent2,MMSContent3,MMSContent4,MMSContent5,MMSContent6,MMSContent7,MMSContent8,MMSContent9,MMSAttachment0,MMSAttachment1,MMSAttachment2,MMSAttachment3,MMSAttachment4,MMSAttachment5,MMSAttachment6,MMSAttachment7,MMSAttachment8,MMSAttachment9) Values('" +
strPhone + "','" + strChaoSong + "','" + strAnSong + "',getdate(),'" + dtRow["MmsUser"].ToString() + "',1,'" + strTitle + "','" + strNote0 + "','" + strNote1 + "','" + strNote2 + "','" + strNote3 + "','" + strNote4 + "','" + strNote5 + "','" + strNote6 + "','" + strNote7 + "','" + strNote8 + "','" + strNote9 + "','" + strAttachment0 + "','" + strAttachment1 + "','" + strAttachment2 + "','" + strAttachment3 + "','" + strAttachment4 + "','" + strAttachment5 + "','" + strAttachment6 + "','" + strAttachment7 + "','" + strAttachment8 + "','" + strAttachment9 + "')";
strSqlNewFlag = "update SendingMmsTable set NewFlag="+countNewFlag+" where MMSindex =" + Mms_ID;
}
dTable = null;
if (strPhone != "")
{
//彩信发送
//首先必须将本地文件上传到彩信猫
ArrayList a = m_MMSFileManage.CommFileUPL(comm, arrayStrAttachMent);
foreach (object intValue in a)
{
if ((int)intValue != 1)
{
countNewFlag++;
UpdateDataBase(strSqlNewFlag);
return 0;
}
}
if (m_MMSSend.SetRecver(strPhone, comm, 1) == 1)
{
if (m_MMSSend.SetRecver(strChaoSong, comm, 2) == 1)
{
if (m_MMSSend.SetRecver(strAnSong, comm, 3) == 1)
{
if (m_MMSSend.SetRecver(strTitle, comm, 4) == 1)
{
foreach (object str in arrayStrAttachMent)
{
if (((string)str).Length != 0)
{
count++;
int position = ((string)str).LastIndexOf("\\");
string filename = ((string)str).Substring(position + 1);
if (m_MMSSend.SetMMSobject(filename, comm, count) != 1)
{
countNewFlag++;
UpdateDataBase(strSqlNewFlag);
return 0;
}
}
}
int countStrnote = 0;
foreach (object strnote in arrayStrNote)
{
if (strnote.ToString().Length != 0)
{
countStrnote++;
if (m_MMSSend.SetMMSsubject((string)strnote, comm, countStrnote) != 1)
{
countNewFlag++;
UpdateDataBase(strSqlNewFlag);
return 0;
}
}
}
//设置彩信的模式
if (m_MMSSend.SetMMSMode(comm, int.Parse(mmsMode)) == 1)
{
Thread.Sleep(1000);
//发送彩信
state = m_MMSSend.SendMMS(comm);
} if (state == 1) //发送成功
{
intRe = UpdateDataBase(strSql);
if (intRe > 0)
{
strSql = "Delete From SendingMmsTable Where MmsIndex=" + Mms_ID;
intRe = UpdateDataBase(strSql);
}
return 1; }
}
}
}
}
}
countNewFlag++;
UpdateDataBase(strSqlNewFlag);
return 0;
其中countNewFlag 已经等于2了,可是却发现strSqlNewFlag 还是"update SendingMmsTable set NewFlag=1where MMSindex =6,其中1是我初始化变量的时候赋的
为什么呀,好像给字符串引用赋值失败了???
public int GetMms(SerialPort comm, int Mms_ID)
{
int state = 0, intRe = 0;
int countNewFlag = 1;
int count = 0;
String strSql, strPhone = "", /*strNote = "",*/strTitle ="",/*strAttachment ="" ,*/ mmsMode ="",strSqlNewFlag="";
DataTable dTable;
try
{
//遍历表的每列并将文本文字和附件的地址分别放到数组中,以便于使用
strSql = "Select Top 1 * From SendingMmsTable Where MmsIndex=" + Mms_ID;
dTable = this.SelectDataBase(strSql);
ArrayList arrayStrNote = new ArrayList();
......
mmsMode = dtRow["MMSMode"].ToString(); strSql = "Insert Into SentMmsTable(PhoneNumber,ChaoSongNumber,AnSongNumber,MmsTime,MmsUser,Status,MmsTitle,MMSContent0,MMSContent1,MMSContent2,MMSContent3,MMSContent4,MMSContent5,MMSContent6,MMSContent7,MMSContent8,MMSContent9,MMSAttachment0,MMSAttachment1,MMSAttachment2,MMSAttachment3,MMSAttachment4,MMSAttachment5,MMSAttachment6,MMSAttachment7,MMSAttachment8,MMSAttachment9) Values('" +
strPhone + "','" + strChaoSong + "','" + strAnSong + "',getdate(),'" + dtRow["MmsUser"].ToString() + "',1,'" + strTitle + "','" + strNote0 + "','" + strNote1 + "','" + strNote2 + "','" + strNote3 + "','" + strNote4 + "','" + strNote5 + "','" + strNote6 + "','" + strNote7 + "','" + strNote8 + "','" + strNote9 + "','" + strAttachment0 + "','" + strAttachment1 + "','" + strAttachment2 + "','" + strAttachment3 + "','" + strAttachment4 + "','" + strAttachment5 + "','" + strAttachment6 + "','" + strAttachment7 + "','" + strAttachment8 + "','" + strAttachment9 + "')";
strSqlNewFlag = "update SendingMmsTable set NewFlag="+countNewFlag+" where MMSindex =" + Mms_ID;
}
dTable = null;
if (strPhone != "")
{
//彩信发送
//首先必须将本地文件上传到彩信猫
ArrayList a = m_MMSFileManage.CommFileUPL(comm, arrayStrAttachMent);
foreach (object intValue in a)
{
if ((int)intValue != 1)
{
countNewFlag++;
UpdateDataBase(strSqlNewFlag);
return 0;
}
}
if (m_MMSSend.SetRecver(strPhone, comm, 1) == 1)
{
if (m_MMSSend.SetRecver(strChaoSong, comm, 2) == 1)
{
if (m_MMSSend.SetRecver(strAnSong, comm, 3) == 1)
{
if (m_MMSSend.SetRecver(strTitle, comm, 4) == 1)
{
foreach (object str in arrayStrAttachMent)
{
if (((string)str).Length != 0)
{
count++;
int position = ((string)str).LastIndexOf("\\");
string filename = ((string)str).Substring(position + 1);
if (m_MMSSend.SetMMSobject(filename, comm, count) != 1)
{
countNewFlag++;
UpdateDataBase(strSqlNewFlag);
return 0;
}
}
}
int countStrnote = 0;
foreach (object strnote in arrayStrNote)
{
if (strnote.ToString().Length != 0)
{
countStrnote++;
if (m_MMSSend.SetMMSsubject((string)strnote, comm, countStrnote) != 1)
{
countNewFlag++;
UpdateDataBase(strSqlNewFlag);
return 0;
}
}
}
//设置彩信的模式
if (m_MMSSend.SetMMSMode(comm, int.Parse(mmsMode)) == 1)
{
Thread.Sleep(1000);
//发送彩信
state = m_MMSSend.SendMMS(comm);
} if (state == 1) //发送成功
{
intRe = UpdateDataBase(strSql);
if (intRe > 0)
{
strSql = "Delete From SendingMmsTable Where MmsIndex=" + Mms_ID;
intRe = UpdateDataBase(strSql);
}
return 1; }
}
}
}
}
}
countNewFlag++;
UpdateDataBase(strSqlNewFlag);
return 0;
要放在后面定义 也就是每次改变countNewFlag都要重新对strSqlNewFlag 赋值。先前定义已经固定了strSqlNewFlag 的值了。当然一直是1了(循环没有意义了)。
要放在后面定义 也就是每次改变countNewFlag都要重新对strSqlNewFlag 赋值。先前定义已经固定了strSqlNewFlag 的值了。当然一直是1了(循环没有意义了)。