各位高手请看下面程序:
Dim ds As New DataSet
Dim Ada As SqlCeDataAdapter
Dim connString As String = "Data Source =\存储卡\rggl\data\biaozhun.sdf;"
Dim cb As New SqlCeCommandBuilder
conn.ConnectionString = connString
conn.Open()
Dim query As String = "SELECT * from biaozhun where ar=2"
Ada = New SqlCeDataAdapter(query, conn)
cb.DataAdapter = Ada
Ada.Fill(ds, "biaozhun")
DataGrid1.DataSource = ds.Tables("biaozhun")
错误在 Ada.Fill(ds, "biaozhun") 提示为数据转换失败。 [ OLE DB status value (if known) = 2 ]
当查询结果为1个时datagrid可显示,但是查询结果为两个时就是上面的错误!
我想实现的功能是查询sdf文件并在datagrid中显示!
请各位高手指教!!!!
SqlCeDataAdapter好像只能返回单列的!求可返回多列的操作
public DataSet GetList(string ipara1, string ipara1, string ipara2,
string ipara3)
{
string sql;
DataSet ds = new DataSet();
sql = "SELECT * FROM yourdatabaseTable WHERE 0=0";
if (ipara1.Length > 0)
sql += " AND para1=" + ipara1;
if (ipara2.Length > 0)
sql += " AND para2 LIKE '%" + ipara2+ "%'";
if (ipara3.Length > 0)
sql += " AND para3='" + ipara3 + "'";
da.SelectCommand.CommandText = sql;
da.Fill(ds, "SignBaseTableList");
da.SelectCommand.CommandText = defaultSQL;
return ds;
}
当查询结果为1个时datagrid可显示,但是查询结果为两个时就是上面的错误!
-----------
什么意思,是指数据行数吗?
另外biaozhun表有主键吗?
有主键,我的意思是当查询有两个或两个以上时发生“错误在 Ada.Fill(ds, "biaozhun") 提示为数据转换失败。 [ OLE DB status value (if known) = 2 ]
”当查询结果只有一个时候程序可正常运行!请大侠帮忙分析分析!!