运行出错啦,怎么办?

bangle 2004-12-16 12:19:01
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
if(Table1->Active)
{
Table1->Close();
}
GetAlias(Sender);
}
//---------------------------------------------------------------------------
void _fastcall TForm1::GetAlias(TObject *Sender)
{
int i;
int j;
int k;

AnsiString tempstr1;
AnsiString tempstr2;
AnsiString tempstr3;
AnsiString strValue;

ListBox1->Items->Clear();
Session1->GetAliasNames(ListBox1->Items);

TTreeNode *tempNode;
TreeView1->Items->Clear();
for(i=0;i<ListBox1->Items->Count;i++)
{
tempstr1=ListBox1->Items->Strings[i];
TreeView1->Items->Add(NULL,tempstr1);
ListBox2->Items->Clear();
tempNode=TreeView1->Items->Item[i];
tempNode->ImageIndex=1;
strValue=tempNode->Text;
Session1->GetTableNames(strValue,"",false,false,ListBox2->Items);

for(j=0;j<ListBox2->Items->Count;j++)
{
tempstr2=ListBox2->Items->Strings[i];
TreeView1->Items->AddChild(tempNode,tempstr2);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TreeView1Click(TObject *Sender)
{
AnsiString tname;
int i,j,k,m;
TListItem *ListItem;
TField *Field;

tname=TreeView1->Selected->Text;
switch(TreeView1->Selected->Level)
{
case 0:
ListView1->Columns->Clear();
break;

case 1:
{
if(Table1->Active)
Table1->Close();
Table1->DatabaseName=ListBox1->Items->Strings[0];
Table1->TableName=tname;
Table1->Active=true;
ListBox3->Items->Clear();
Table1->GetFieldNames(ListBox3->Items);
ListView1->Columns->Clear();
ListView1->Items->Clear();

for(k=0;k<ListBox3->Items->Count;k++)
{
TListColumn *NewColumn;

NewColumn=ListView1->Columns->Add();
NewColumn->Caption=ListBox3->Items->Strings[k];
Table1->First();
while(!Table1->Eof)
{
ListItem=ListView1->Items->Add();
ListItem->Caption=Table1->FieldByName(NewColumn->Caption)->AsString;
ListItem->ImageIndex=6;
for(m=1;m<ListBox3->Items->Count;m++)
{
Field=Table1->Fields->Fields[m];
ListItem->SubItems->Add(Field->AsString);
}
Table1->Next();
}
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ToolButton1Click(TObject *Sender)
{
ListView1->ViewStyle=vsSmallIcon;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ToolButton2Click(TObject *Sender)
{
ListView1->ViewStyle=vsIcon;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ToolButton3Click(TObject *Sender)
{
ListView1->ViewStyle=vsList;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ToolButton4Click(TObject *Sender)
{
ListView1->ViewStyle=vsReport;
}

运行后出现:Error对话框.
Project Project1.exe raised exception class EDBEngineError with message 'Unknown
database.
Alias:animals'.Process stopped.Use Step or Run to continue.
...全文
162 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
bangle 2005-01-17
  • 打赏
  • 举报
回复
up
特招 2005-01-02
  • 打赏
  • 举报
回复
up
samchoy 2004-12-20
  • 打赏
  • 举报
回复
void _fastcall TForm1::GetAlias(TObject *Sender)
{
int i;
int j;
int k;

AnsiString tempstr1;
AnsiString tempstr2;
AnsiString tempstr3;
AnsiString strValue;

ListBox1->Items->Clear();
Session1->GetAliasNames(ListBox1->Items);

TTreeNode *tempNode;
TreeView1->Items->Clear();
for(i=0;i<ListBox1->Items->Count;i++)
{
tempstr1=ListBox1->Items->Strings[i];
TreeView1->Items->Add(NULL,tempstr1);
ListBox2->Items->Clear();
tempNode=TreeView1->Items->Item[i]; // 这里出问题了,此处得到的Node是按绝对顺序排列的,也就是说,当i == 1时,tempNode得到的是第一个Alias(BCDEMOS)下的第一个表animals,而不是你想要的第二个Alias,所以会出这个错误
tempNode->ImageIndex=1;
strValue=tempNode->Text;
Session1->GetTableNames(strValue,"",false,false,ListBox2->Items);

for(j=0;j<ListBox2->Items->Count;j++)
{
tempstr2=ListBox2->Items->Strings[i];
TreeView1->Items->AddChild(tempNode,tempstr2);
}
}
}
Amour81 2004-12-16
  • 打赏
  • 举报
回复
系统没找到你指定的Animal数据库
bangle 2004-12-16
  • 打赏
  • 举报
回复
有解决的方案吗?
free1688 2004-12-16
  • 打赏
  • 举报
回复
数据库没链接成功
milkwayhong 2004-12-16
  • 打赏
  • 举报
回复
数据库别名animals的问题
lihongxing2002 2004-12-16
  • 打赏
  • 举报
回复
指定的数据库不存在

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧