用户未处理的异常 [英] Unhandeled Exception by user

查看:319
本文介绍了用户未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,出现错误,提示用户未处理.

Here is my code where I am getting an error that says Unhandled by the user.

string connection =  "Data Source=C:\\Documents andSettings\\Administrator\\My Documents\\my1.mdb";
string cl = DropDownList1.SelectedItem.Text;
string query= "Select * from fee where course=''cl''"; AccessDataSource ads = new AccessDataSource("C:\\Documents and Settings\\Administrator\\My Documents\\my1.mdb", query);
GridView1.DataSource = ads;
GridView1.DataSourceID = String.Empty;
GridView1.DataBind();



在这里,我想从下拉列表中获取字符串.并且在数据库中有一个名为课程的专栏.我想获取该特定课程的数据.

[edit]已添加代码块,忽略HTML ..."选项已禁用-OriginalGriff [/edit]



Here I want to get string from dropdownlist. And in database there is one coloum named course. I want to fetch data for that particular course.

[edit]Code block added, "Ignore HTML..." option disabled - OriginalGriff[/edit]

推荐答案

您需要进行如下更改才能通过下拉列表对数据库的价值.下面以底线突出显示.

You need to change like below to pass the dropdown list value to database. Below in highlighted with underline.

string connection = "Data Source=C:\\Documents andSettings\\Administrator\\My Documents\\my1.mdb";
          string cl = DropDownList1.SelectedItem.Text;
          string query = "Select * from fee where course=" + c1; AccessDataSource ads = new AccessDataSource("C:\\Documents and Settings\\Administrator\\My Documents\\my1.mdb", query);
          GridView1.DataSource = ads;
          GridView1.DataSourceID = String.Empty;
          GridView1.DataBind();



希望对您有所帮助.



Hope it helps.


这篇关于用户未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆