how to connect to database

I want to connect to database with a variable name,,,,,,,,,,,,(test=database name),,,,,,,,,(a(variable)=test),,,,,,,conn=database('test','','')is the method to connect right,,,,,but i want to connect using variable name,,, conn=database('a','',''),,,,because everytimr my datase file will be selected by user,,,,

1 件のコメント

Arun Badigannavar
Arun Badigannavar 2012 年 11 月 22 日
how to perform this,,,everytime my database will be changing

回答 (1 件)

Titus Edelhofer
Titus Edelhofer 2012 年 11 月 22 日

0 投票

Hi,
the question is not really clear. Do you mean the following?
a = 'test'; % input from user, e.g., by GUI or input
% use the variable a as database name:
d = database(a, ...);
This works fine as long as the user passes a "known" database name ...
Titus

3 件のコメント

Arun Badigannavar
Arun Badigannavar 2012 年 11 月 23 日
one more question is ,I want to access different tables everytime in a single database
Titus Edelhofer
Titus Edelhofer 2012 年 11 月 23 日
The tables are specified when you read data, e.g.
tableName = 'customers';
curs = exec(['SELECT * FROM ' tableName]);
Titus
Arun Badigannavar
Arun Badigannavar 2012 年 11 月 23 日
here table is 'customers' ,,,and u r giving it to 'tableName' right?

この質問は閉じられています。

タグ

質問済み:

2012 年 11 月 22 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by