| |

VerySource

 Forgot password?
 Register
Search
View: 1878|Reply: 8

anxious! !! !! How to use DBGrid to display the contents of another data table? (Wait for answers online)

[Copy link]

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-13 14:40:01
| Show all posts |Read mode
I use ADOConnection1 + ADOTable1 + DataSource1 + DBGrid1 to access the Access database, but DBGrid can only display the linked tables, and somehow dynamically link other tables.
  It is to use a button to excite another table and display it in the current DBGrid.
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-17 13:45:02
| Show all posts
Wouldn't adotable-> tablename = "you want a table" work?
For example: the table you want is: table, write in a button click event:
adotable-> active = false;
adotable-> tablename = "table";
adotable-> active = true;
That should do it.
Reply

Use magic Report

0

Threads

15

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-1-28 21:09:02
| Show all posts
Did not understand, do you want to display two tables in a DBGrid, or do you want to display two different tables in two DBGrid?
Reply

Use magic Report

0

Threads

15

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-1-28 21:27:01
| Show all posts
I suggest that the Lord make the problem clear, and others can help you ~
Reply

Use magic Report

0

Threads

16

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-1-29 11:45:01
| Show all posts
Change the name of tablename and reopen
Otherwise, just use the adoquery control, and you can use some sql statements.
Reply

Use magic Report

0

Threads

12

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-1-29 22:00:01
| Show all posts
Everyone makes sense
Reply

Use magic Report

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-2-1 16:45:01
| Show all posts
What I mean is that the table in the current DBGrid is replaced with the contents of another table, not the two tables are merged. (Use a button to change)
It hasn't been solved so far. I haven't used the following methods.

Form_yhzlgl-> ADOConnection1-> DefaultDatabase = "D:\hnsfot_mrp\Access\student_01";
Form_yhzlgl-> ADOConnection1-> LoginPrompt = false;
Form_yhzlgl-> ADOConnection1-> Connected = true;
           // Set ADOConnection1
Form_yhzlgl-> ADOTable1-> Connection = ADOConnection1;
Form_yhzlgl-> ADOTable1-> TableName = "Table name";
Form_yhzlgl-> ADOTable1-> Active = true;
           // Set ADOTable1
Form_yhzlgl-> DataSource1-> DataSet = ADOTable1;
           // Set DataSource1
Form_yhzlgl-> DBGrid1-> DataSource = DataSources1;
           // Set DBGrid1
Reply

Use magic Report

0

Threads

15

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-2-5 09:45:01
| Show all posts
Never used ACCESS, SQL Server implementation seems very simple.
void __fastcall TForm1 :: Button1Click (TObject * Sender)
{
  ADOQuery1-> Close ();
  ADOQuery1-> SQL-> Clear ();
  ADOQuery1-> SQL-> Text = "select * from biao2";
  ADOQuery1-> Open ();
}
Reply

Use magic Report

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Localhost

 Author| Post time: 2020-2-9 20:30:01
| Show all posts
This issue has been resolved, thank you for your participation!
  I am not grateful.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list