C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




tablename


Posted Date: 29 Aug 2008      Total Responses: 3

Posted By: kalaimanichozhan       Member Level: Gold     Points: 1


How to get all table names in a database into arraylist.



Responses

Author: Sandeep Chougule    30 Aug 2008Member Level: GoldRating:     Points: 6
Hi check this
All table name inserted into combo
Same this u can add names in Array list



cmm = new SqlCommand();
cmm.Connection = con;
cmm.CommandType = CommandType.Text;
cmm.CommandText = " select name from sys.tables";
SqlDataAdapter da = new SqlDataAdapter(cmm);
DataTable dt = new DataTable();
da.Fill(dt);
DataView dv=new DataView(dt);
cmbDatabase.DataSource = dv;
cmbDatabase.DataTextField = "name";
cmbDatabase.DataBind();
con.Close();



Author: Vidhya    30 Aug 2008Member Level: GoldRating:     Points: 6
hi,

Here is an example:

PERSON:
==========

package adf.dc.test;

public class Person {

private String name;
private String firstname;
private String address;
private String zip;
private String city;

public Person() {
}

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setFirstname(String firstname) {
this.firstname = firstname;
}

public String getFirstname() {
return firstname;
}

public void setAddress(String address) {
this.address = address;
}

public String getAddress() {
return address;
}

public void setZip(String zip) {
this.zip = zip;
}

public String getZip() {
return zip;
}

public void setCity(String city) {
this.city = city;
}

public String getCity() {
return city;
}
}


PERSONS MODEL
===============

package adf.dc.test;

import java.util.ArrayList;
import java.util.List;

public class DCModelSrc {

private Person p;
List<Person> al = new ArrayList<Person>();

public DCModelSrc() {


for (int i = 0; i < 10; i++) {
p = new Person();
p.setName(i+"_Lastname");
p.setFirstname(i+"_Firstname");
p.setAddress(i+"_Address");
p.setZip(i+"_Zip");
al.add(p);
}
}


public List<Person> getModel(){
return al;
}



}

CREATING THE DATACONTROL
========================

Select the "DCModelSrc" entry and choose "Create Datacontrol" from the context menu. Open a View project and drag the model entry as a table.

Happy programming!



Author: Rajesh(March-2008 Winner)    30 Aug 2008Member Level: GoldRating:     Points: 3
select * from sqlite_master where type = 'table'

Right. That will work for SQLite. Or you can just use the TableSchemas method of the Database class and the REAL SQL Database will do it for you.


Post Reply
You must Sign In to post a response.
Next : Metadata
Previous : database
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

accuconference

Contact Us    Privacy Policy    Terms Of Use