G
gyang
Unregistered / Unconfirmed
GUEST, unregistred user!
我在程序上放上以下C#控件
sqlConnection1,sqlDataAdapter1(生成adsTemp1)
sqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM TableName";
表中有7个字段2000行数据
如果这样打开(要3-4秒钟,和Delphi的用ADO连接(0.几秒)相比,相差太大):
sqlConnection1.Open();
sqlDataAdapter1.Fill(adsTemp1);
而且浏览数据也时分不方便:
MessageBox.Show(adsTemp1.Tables["CodeItems"].Rows[2]["CodeItemName"].ToString());
我想,是我的方法不正确,请教就如何写
如:Delphi的如下
{已有以下两个ADO控件ADOConnection1(ADOConn),ADODataSet1(adsTemp1)}
procedure ADOTest;
begin
with adsTemp1do
begin
if Active then
Active := False;
CommandText := 'SELECT Field1,Field2,Field3,Field4 FROM TableName';
Active := True;
while not Eofdo
begin
ShowMessage(FieldByName("Field1").AsString + ' ' +Fields[1].AsString);
if FieldByName('Field3').AsInteger = 1 then
Prior//上一条记录
else
FieldByName('Field4').AsString = 'S' then
Last//最后一条记录
else
Next;
end;
end;
sqlConnection1,sqlDataAdapter1(生成adsTemp1)
sqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM TableName";
表中有7个字段2000行数据
如果这样打开(要3-4秒钟,和Delphi的用ADO连接(0.几秒)相比,相差太大):
sqlConnection1.Open();
sqlDataAdapter1.Fill(adsTemp1);
而且浏览数据也时分不方便:
MessageBox.Show(adsTemp1.Tables["CodeItems"].Rows[2]["CodeItemName"].ToString());
我想,是我的方法不正确,请教就如何写
如:Delphi的如下
{已有以下两个ADO控件ADOConnection1(ADOConn),ADODataSet1(adsTemp1)}
procedure ADOTest;
begin
with adsTemp1do
begin
if Active then
Active := False;
CommandText := 'SELECT Field1,Field2,Field3,Field4 FROM TableName';
Active := True;
while not Eofdo
begin
ShowMessage(FieldByName("Field1").AsString + ' ' +Fields[1].AsString);
if FieldByName('Field3').AsInteger = 1 then
Prior//上一条记录
else
FieldByName('Field4').AsString = 'S' then
Last//最后一条记录
else
Next;
end;
end;