从oracle中查出数据绑定到GridView
我是这样做的:
OracleConnection mycnn = new OracleConnection("connectionString");
OracleDataAdapter oda = new OracleDataAdapter("select * from NEWGONGWENSP2_FC where FLOWCODE=" + FLOWCODE , mycnn);
DataSet dataset = new DataSet();
oda.Fill(dataset, "connectionString");
//实现点击表头排序
DataView view = dataset.Tables["connectionString"].DefaultView;
string sort = (string)ViewState["SortOrder"] + " " + (string)ViewState["OrderDire"];
view.Sort = sort;
GridView1.DataSource = view;
GridView1.DataKeyNames = new String[] { "id" };
GridView1.DataBind();
可报错:“从索引 0 处开始,初始化字符串的格式不符合规范。 ”
大家给看看搓出在那里?如果有跟好的办法请给小弟代码说明。
------解决方案--------------------哪一句报错
------解决方案--------------------OracleConnection mycnn = new OracleConnection("connectionString");
"connectionString" 改成 oracle的连接字符串。
------解决方案--------------------OracleConnection mycnn = new OracleConnection("connectionString");
=>
OracleConnection mycnn = new OracleConnection("Data Source=mapgisoaNET10;User ID=gt001;Password=gt001;");
------解决方案--------------------string strconn = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
这句话搞错对象了。。。
=>
ConfigurationManager.AppSettings["connectionString"]
------解决方案--------------------
------解决方案--------------------<--config-->
<add name="OracleConnectionString" connectionString="Password=sa;User ID=sa;Data Source=orcl_DB;Persist Security Info=True" providerName="System.Data.OracleClient"/>
<-页面->
string strConn= ConfigurationManager.AppSettings["OracleConnectionString"]
------解决方案--------------------SQL code
select * from newgongwensp2_fc where 标题 like'%21%' and PERSONNAME like'%张力学%' and flowcode='20124' order by OPINIONDATE