Copy link to clipboard
Copied
I am using the built in cold fusion server.. and I have a table called access from the wwwroot folder on the datasource.. my question is.. i made another table just called table1, but how would i get that in the datasource? its also in the wwwroot folder, and when i try to put it on it says:
Trying to create a datasource with a name that is the same as an existing datasource.
Please enter in a unique datasource name, or edit the existing datasource.
Soooooo does it see all the tables in the wwwroot folder? Or do I need to put them in different folders? Sorry I'm a n00b only on day 9 of my Learn ColdFusion in 21 Days, book.
Copy link to clipboard
Copied
Hi,
You need to create a database first, and after doing that, create your tables under that database, once you complete that, you can create your datasource in the CFAdministrator pointing to that database.
Copy link to clipboard
Copied
Welcome to ColdFusion, unfortunately you're leaving out some very important information such as what database type you're working with (such as Microsoft SQL, MySQL, Microsoft Access). Here's a quick rundown on how ColdFusion works in terms of setting up and accessing a database.
First, choose what type of database you're going to use: Microsoft SQL, MySQL, and Microsoft Access are all examples. For security reasons, if you use Microsoft Access, do not store your database (the .mdb file) within your wwwroot folder, but instead store it above the wwwroot folder, or in a password-protected folder. This will prevent someone from finding out where your database is stored, and then downloading it by typing it's URL directly into their Internet browser.
Second, create the database, and create whatever tables you need within that database. Since you're just starting out, you only probably need one database. Create one table within that database to store data, or create many, it all depends on what the needs of your ColdFusion application will be.
Third, tell ColdFusion where to find your database by creating an ODBC datasource from within ColdFusion administrator. You can usually access this by going to http://localhost/cfide/administrator/, or a slight variation thereof depending on your installation. On a Windows install they throw a shortcut to it within the ColdFusion folder found within "Start/Programs/". Be prepared to tell ColdFusion information about what type of database you are using.
From here, the sky is the limit. Add the name of the datasource you created in ColdFusion administrator to your database queries as such:
<CFQUERY NAME="myquery" DATASOURCE="mydatasource" DBTYPE=ODBC>
...
I'd go into more detail, and throw some tips your way, but you seem like you're still dipping into the water, but feel free to post if you have more questions.