private void btOk_Click(object sender, EventArgs e)
{
String strSQL;
if (m_bInsert)
{
if (txtNum.Text == "")
{
MessageBox.Show("期号不能为空");
return;
}
strSQL = "INSERT INTO 表1 VALUES('" + txtNum.Text + "','" + comRed1st.Text + ",'" + comRed2nd.Text + "','"
+ comRed3rd.Text + "','" + comRed4th.Text+ "','"
+ comRed5th.Text + "','" + comRed6th.Text + "','" + comBlue.Text + "') ";
}
OleDbConnection oleDbConn = null;
try
{
oleDbConn = new OleDbConnection(Properties.Resources.ConnectionString);
oleDbConn.Open();
OleDbCommand oleDbComm = new OleDbCommand(strSQL, oleDbConn);
oleDbComm.ExecuteNonQuery();
if (m_bInsert)
{
MessageBox.Show("插入成功!");
}
}
catch (OleDbException)
{
if (m_bInsert)
{
MessageBox.Show("插入失败!");
}
}
finally
{
oleDbConn.Close();
}
Dispose();
}错误提示我说 使用了未赋职的局部变量"strSQL"小弟第一次提问没多少分
{
String strSQL;
if (m_bInsert)
{
if (txtNum.Text == "")
{
MessageBox.Show("期号不能为空");
return;
}
strSQL = "INSERT INTO 表1 VALUES('" + txtNum.Text + "','" + comRed1st.Text + ",'" + comRed2nd.Text + "','"
+ comRed3rd.Text + "','" + comRed4th.Text+ "','"
+ comRed5th.Text + "','" + comRed6th.Text + "','" + comBlue.Text + "') ";
}
OleDbConnection oleDbConn = null;
try
{
oleDbConn = new OleDbConnection(Properties.Resources.ConnectionString);
oleDbConn.Open();
OleDbCommand oleDbComm = new OleDbCommand(strSQL, oleDbConn);
oleDbComm.ExecuteNonQuery();
if (m_bInsert)
{
MessageBox.Show("插入成功!");
}
}
catch (OleDbException)
{
if (m_bInsert)
{
MessageBox.Show("插入失败!");
}
}
finally
{
oleDbConn.Close();
}
Dispose();
}错误提示我说 使用了未赋职的局部变量"strSQL"小弟第一次提问没多少分
解决方案 »
- 网上下载的.net程序需要怎么调试啊(web.config)
- TreeView怎么与Frame一起用×××××××××××××××××××
- Winform中对dataGrid中行记录的双击问题...
- datagrid中同时选中多行?
- 谁有BeaGle的Windows版本源代码(C#)或其他一些Desktop Search的代码?
- 用SQLDMO组件进行数据库备份时,为什么备份文件只能在驱动器根目录下
- 关于字体重新设置格式的问题
- 关于c#制作类似QQ的 抽屉效果的问题
- C#下怎样把资源文件resources连接到一个窗体?
- SQL语句创建表
- 100分求解!!!
- 在C#编程中,什么时候需要线程睡眠?
看看下面的怎么说了
如果真错了,给 String strSQL赋个初始值试试