代码如下:private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (comboBox2.DataSource!=null)
{
string sql="select year(enrolmenttime) from classinfo where classid="+comboBox2.SelectedValue;
OleDbCommand cmd=new OleDbCommand(sql,oleDbConnection1);
int rxnf=Int32.Parse(cmd.ExecuteScalar().ToString());
sql="select length from classinfo where classid="+comboBox2.SelectedValue;
cmd.CommandText=sql;
int nianzhi=Int32.Parse(cmd.ExecuteScalar().ToString());
comboBox3.Items.Clear();
int nf=rxnf;
Object item=new object();
for (int i=1;i<=nianzhi*2;i++)
{
string str = String.Format("{0}-{1}年度第{2}学期", nf, nf + 1, ((i + 1) % 2 + 1));
comboBox3.Items.Add(str);
if (i%2==0) nf++;
}
}
else
{
comboBox3.SelectedIndex=-1;
comboBox3.Items.Clear();
}错误如下:
System.FormatException: 输入字符串的格式不正确。
在 System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
在 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
在 System.Int32.Parse(String s)
在 WindowsApplication1.AddCourse.comboBox3_SelectedIndexChanged(Object sender, EventArgs e) 位置 C:\Documents and Settings\Administrator\桌面\学生管理系统\AddCourse.cs:行号 478
在 System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
在 System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
在 System.Windows.Forms.ComboBox.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3603 (GDR.050727-3600)
基本代码: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
WindowsApplication1
程序集版本: 1.0.3801.34589
Win32 版本: 1.0.3801.34589
基本代码: file:///C:/Documents%20and%20Settings/Administrator/桌面/学生管理系统/bin/Debug/WindowsApplication1.exe
----------------------------------------
System.Windows.Forms
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Configuration
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Transactions
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
mscorlib.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3603 (GDR.050727-3600)
基本代码: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
System.Windows.Forms.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------************** JIT 调试 **************
要启用实时(JIT)调试,
该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
jitDebugging 值。
编译应用程序时还必须启用
调试。例如: <configuration>
<system.windows.forms jitDebugging="true" />
</configuration>启用 JIT 调试后,任何无法处理的异常
都将被发送到在此计算机上注册的 JIT 调试器,
而不是由此对话框处理。
{
if (comboBox2.DataSource!=null)
{
string sql="select year(enrolmenttime) from classinfo where classid="+comboBox2.SelectedValue;
OleDbCommand cmd=new OleDbCommand(sql,oleDbConnection1);
int rxnf=Int32.Parse(cmd.ExecuteScalar().ToString());
sql="select length from classinfo where classid="+comboBox2.SelectedValue;
cmd.CommandText=sql;
int nianzhi=Int32.Parse(cmd.ExecuteScalar().ToString());
comboBox3.Items.Clear();
int nf=rxnf;
Object item=new object();
for (int i=1;i<=nianzhi*2;i++)
{
string str = String.Format("{0}-{1}年度第{2}学期", nf, nf + 1, ((i + 1) % 2 + 1));
comboBox3.Items.Add(str);
if (i%2==0) nf++;
}
}
else
{
comboBox3.SelectedIndex=-1;
comboBox3.Items.Clear();
}错误如下:
System.FormatException: 输入字符串的格式不正确。
在 System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
在 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
在 System.Int32.Parse(String s)
在 WindowsApplication1.AddCourse.comboBox3_SelectedIndexChanged(Object sender, EventArgs e) 位置 C:\Documents and Settings\Administrator\桌面\学生管理系统\AddCourse.cs:行号 478
在 System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
在 System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
在 System.Windows.Forms.ComboBox.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3603 (GDR.050727-3600)
基本代码: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
WindowsApplication1
程序集版本: 1.0.3801.34589
Win32 版本: 1.0.3801.34589
基本代码: file:///C:/Documents%20and%20Settings/Administrator/桌面/学生管理系统/bin/Debug/WindowsApplication1.exe
----------------------------------------
System.Windows.Forms
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Configuration
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Transactions
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
mscorlib.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3603 (GDR.050727-3600)
基本代码: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
System.Windows.Forms.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.3053 (netfxsp.050727-3000)
基本代码: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------************** JIT 调试 **************
要启用实时(JIT)调试,
该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
jitDebugging 值。
编译应用程序时还必须启用
调试。例如: <configuration>
<system.windows.forms jitDebugging="true" />
</configuration>启用 JIT 调试后,任何无法处理的异常
都将被发送到在此计算机上注册的 JIT 调试器,
而不是由此对话框处理。
解决方案 »
- 所请求的剪贴板操作失败
- 简单数字正则。
- wpf ListView嵌套ComboBox,绑定赋值
- 在系统中显示唯一标识是好是坏?
- winfrom里php做插件????
- WebClient的DownloadFile怎么更改路径
- 请问如何在一个线程中锁定某资源,而在另一线程中解除锁定
- 福建省第二届计算机软件大赛作品地址
- 请问private System.ComponentModel.Container components = null是什么意思?
- 一个简单的问题,更是一个令人郁闷至死的问题....!!!(关于DataList 绑定)
- 求解
- 语法错误 (操作符丢失) 在查询表达式 ''计科0501 ','1-2节','无'' 中。
检查length 值
if (null != obj && System.DBNull.Value!=obj)
{}
再转化
是哪一行?
估计是这一行吧?
string str = String.Format("{0}-{1}年度第{2}学期", nf, nf + 1, ((i + 1) % 2 + 1));
在这一句设置断点,看看什么时候,后面的值出现问题。
private void comboBox3_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (comboBox3.Text.Trim()!="")
statusBarPanel2.Text=(int.Parse(comboBox3.Text.Trim())/10)+"-"+(int.Parse(comboBox3.Text.Trim())/10+1)+"年度第"+(int.Parse(comboBox3.Text.Trim())%10)+"学期";
else
statusBarPanel2.Text="";
}
说红色部分 格式不正确。应该怎么改呢????
改成:statusBarPanel2.Text=Convert.ToString((int.Parse(comboBox3.Text.Trim())/10))+"-"+Convert.ToString((int.Parse(comboBox3.Text.Trim())/10+1))+"年度第"+Convert.ToString((int.Parse(comboBox3.Text.Trim())%10))+"学期";
if(!string.isNullOrEmpty(comboBox3.Text.Trim)){}
int.TryParse
int i=0;
int.TryParse("",out i);