YesSoftware CodeCharge
Frequently Asked Questions
ã YesSoftware, Inc.
2226 A. Westborough Blvd. #405
South San Francisco, CA 94080
Phone (650) 754-9810 • (415) 820-7566
Table of Contents
Placing a database in a secure folder
Using ODBC to configure a database connection to a text or csv file
Do I need a database to use CodeCharge ?
Syntax error in INSERT INTO statement. (Microsoft JET Database Engine)
Operation Must Use an Updateable Query
"80004005 "Couldn't Use '(unknown)'; File Already in Use
Login Errors and Issues - can't Login
PHP error : open(temp\/sess_1de7095ab2e3a5ab132abc…, O_RDWR) failed
Update, Delete Buttons donot appear in a record form
Footer on pages generated using Trial software
CodeCharge Standard and Professional
Inserting data into multiple tables
Searching using 'AND' or 'OR' operators in a search
Summary
Symptoms I am trying to execute a search on a Date value stored in an Access database but I
keep on getting an error message on the SQL query. What am I doing wrong?
Resolution MS Access requires date values to be enclosed between a pair of hash marks e.g.
#06/04/01#. This means that if you are performing a search against a date value in
Access, the default SQL which wraps date values between single quotation marks
('06/04/01') will generate an error. To accommodate this nuance, you have to convert
regular dates like 06/04/01 to MS Access compatible date format. You can achieve
this by addiing the following code to the 'Open' event of the grid form which is going
to display the results of the search.
sWhere=replace(sWhere, "'" & GetParam("start_date") & "'", "#" &
GetParam("start_date") & "#")
The replace() function above takes the where clause of the SQL statement and
replaces the single quotation marks with hash marks.
Summary
Symptoms Does CodeCharge support the execution of database stored procecures?
Resolution Although CodeCharge does not have native support for stored procedures, you can
write code to call and execute stored procedures from events. From the list of
available page and form events, select the appropriate one and enter code to call the
stored procedure.
You can call the stored procedure using the default CodeCharge connection object
(cn). However, if you need to get resultsets returned, you need to use a command
object as illustrated below:
Set cmd = CreateObject ("ADODB.Command")
Set rs = CreateObject ("ADODB.Recordset")
Set fldloop = CreateObject ("ADODB.Field")
Set param1 = CreateObject ("ADODB.Parameter")
Set param2 = CreateObject ("ADODB.Parameter")
Set param3 = CreateObject ("ADODB.Parameter")
Set cmd.ActiveConnection = cn
cmd.CommandText = "sp_CPU_DEL"
cmd.CommandType = adCmdStoredProc
' Set up a return parameter.
Set param1 = cmd.CreateParameter("Return", adInteger, adParamReturnValue)
cmd.Parameters.Append param1
' Set up an output parameter.
Set param2 = cmd.CreateParameter("ROWS", adInteger, adParamOutput)
cmd.Parameters.Append param2
' Set up an input parameter.
Set param3 = cmd.CreateParameter("I_CPU_ID", adInteger, adParamInput)
cmd.Parameters.Append param3
param3.Value = CPU_ID
' Execute command, and loop through recordset.
Set rs = cmd.Execute
Dim i As Integer
While Not rs.EOF
For Each fldloop In rs.Fields
' do something with rs.Fields(i)
i = i + 1
Next fldloop
i = 0
rs.MoveNext
Wend
rs.Close
Summary
Symptoms When choosing the language for a project, the ASP options are 'ASP 2.0' and 'ASP
2.0 & Template'. Is the code that CodeCharge generated ASP 3.0 complaint?
Resolution The CodeCharge generated code is both ASP 2.0 and ASP 3.0 complaint.
Summary How do you connect to a MySQL database ?
Symptoms What is the procedure of connecting to a MySQL database.
Resolution You will need to install the MyODBC driver from mysql.com
This is only needed during the design time. The generated programs should be able to
connect directly to the database, by its name.
Here are the general steps:
(Assuming that you already created your MySQL database)
1. Download and install MyODBC from www.mysql.com
2. Setup your ODBC connection in Start -> Control Panel -> ODBC.
3. In CodeCharge, click on Properties -> Database, and on the Yellow icon that
opens OLE Database Providers. Select ODBC and then your ODBC connection
name.
Until now you should be setup enough to use CodeCharge and access the
database during the design time.
Then:
5. You need to add Database Name, Login, Password and specify the Database
Type (MySQL) before generating the programs.
CodeCharge will generate PHPLib, which is the standard library used for direct
database access in PHP programs.
Summary Placing a database in a folder other than that in which the webpages reside.
Symptoms When using Access with a OLEDB 4.0 connection to the database, you have the
option of copying the database to the server. When you copy the database to the
server, the database is placed in the same folder as the web pages and a connection
string is created to point to this location.
However, in the interest of security, you might want to change the location of the
database to a folder which is more secure.
Resolution When publishing a project that uses the 'Microsoft JET OLEDB 4.0 Provider', you
can specify a 'Custom Connection String' to be used in the server. The 'Custom
Connection String' is similar to the 'Design Connection String' that is used within
CodeCharge except that it specifies an alternate location for the database when the
pages are generated to the server. For instance if the 'Design Connection String' is:
Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=E:\CodeCharge\Projects\myProject\MyDatabase.mdb;Persist Security Info=False
and assuming that your pages are placed in a server folder with the path:
C:\Inetpub\wwwroot\myProject
and you want to have them connect to a database located in:
C:\Inetpub\Databases
you would use the connection string:
Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data
Source=C:\Inetpub\Databases\MyDatabase.mdb;Persist Security Info=False
Summary Using ODBC to configure a database connection to a text or csv file
Symptoms Rather than use traditional databases, you might want to use a flatfile database such
as a text file containing comma, tab or otherwise delimited values.
Resolution To begin with, create a Text ODBC datasource name (DSN) on the windows
machine do the following:
1. In Control Panels, open the 'Data Sources (ODBC)' option.
2. Click on the 'System DSN' tab.
3. Click on the 'Add' button.
4. From the list, select the 'Microsoft Text Driver (*.txt; *.csv)' then click finish.
5. In the 'Data Source Name' field, enter a name for your DSN such as 'myDSN'
6. Optionally enter a description for the DSN.
7. De-Select the 'Use Current Directory' checkbox if it is checked.
8. Click on the 'Select Directory' button and navigate to the directory where your .csv
file is located and click 'Ok'.
9. Click 'Ok' to close the ODBC window.
With your ODBC DSN created, you are now ready to connect to it from within
CodeCharge:
1. In the Site-->Properties-->Database tab, click on the yellow Icon.
2. In the 'Provider' tab, select 'Microsoft OLE DB Provider for ODBC Drivers'
3. In the 'Connection' tab, use the 'Use data source name' listbox to select the DSN
you created above (MyDSN).
4. Click on the 'Test Connection' button to ensure that the connection is working.
5. Click 'Ok' to close the window.
With this done, you can now go ahead and create pages using the data in the .csv file.
Summary
Symptoms How do I connect to a databse using the PERL language
Resolution To connect to a database using PERL, you need to download and install the
necessary DBI modules. Refer to the following locations for the modules:
http://www.cpan.org/modules/by-category/07_Database_Interfaces/
http://dbi.symbolstone.org
Summary
Symptoms Help! How do I install MyODBC to connect to a MySQL server
Resolution Refer to the tutorials located at http://support.yessoftware.com/tutorials.asp for
comprehensive instructions on how to install and configure MyODBC.
Summary
Symptoms I am using a MySQL database that is located on a remote ISP's machine or a
machine that I don't have direct access to. I understand that I have to install and
configure MyODBC so as to enable CodeCharge to connect to the MySQL
database. Do I have to install MyODBC on the remote server?
Resolution You don't need to install MyODBC on the remote server so be able to connect to the
database using MyODBC. MyODBC is required to be installed only on the local
machine where CodeCharge is located. Once you install MyODBC, you can use it to
configure a ODBC data source name (DSN) which will link to the MySQL database
on the remote server and allow CodeCharge to interact with the database.
Summary Do I need a database to use CodeCharge ?
Symptoms Is it possible to create a CodeCharge Project without using a database?
Resolution The main purpose of CodeCharge is to allow you to create dynamic database driven
websites. You therefore need to have a database to connect to the project so as to
achieve this goal. CodeCharge does not create the database so you will have to
create this yourself. Theoretically, you can create a project without a database but
there is little reason why you would want to do so. CodeCharge will generate error
messages when you try to generate a project that is not connected to a database but
you can choose to ignore this message.
Summary Syntax error in INSERT INTO statement. (Microsoft JET Database Engine)
Symptoms When inserting a new record on the page, the following error occurs: Syntax error in
INSERT INTO statement. (Microsoft JET Database Engine).
This error may occur when:
1. A database table name has a space ( ) in it, for example ""Job Quotes"".
2. A database table or field is named using a reserved keyword in Visual Basic /
ASP, for example ""user"", ""password"", ""month"", ""date"", etc.
Resolution Change your database table or field name by renaming it to a non-conflicting name,
for example rename "Job Quotes" to "Job_Quotes" or rename "month" to "tblmonth"
Summary ASP Returns Error "Operation Must Use an Updateable Query"
Symptoms When you try to add a new record or update an existing record, you get the Error
"message Operation Must Use an Updateable Query".
Resolution The error you are getting indicates that the database access permissions are not set
correctly. For starters, if you are using Windows NT or 2000, please set the security
on the .mdb file and its parent directory to "full-access". If you use Windows
95/98/Me, right-click on the .mdb file and make sure that "read-only" is unchecked,
then do the same on the directory where your .mdb file is located. Also, note the
following:
1) This error may occur if the account being used by Internet Information Server
(IIS), (usually IUSR), does not have the correct Windows NT permissions for a
file-based database or for the folder containing the file.
2) Use the Windows NT File Monitor to check for file access failures. Windows NT
File Monitor is available from the following Web site: <http://www.sysinternals.com>.
3) If you use a network path to the database (UNC or mapped drive), check the
permissions on the share, the file, and the folder.
4) Check to make sure that the file and the data source name (DSN) are not marked
as Exclusive.
5) Make sure no other process uses this mdb file.
6) This error may also occur when accessing a local Microsoft Access database
linked to a table where the table is in an Access database on a network server. In this
situation, please refer to the following article in the Microsoft Knowledge Base for a
workaround.
This error is attributed to the design of Microsoft products and you can read more
about it at:
Summary Error: "80004005 "Couldn't Use '(unknown)'; File Already in Use"
Symptoms When you try running an ASP project, you get the error message: "80004005
"Couldn't Use '(unknown)'; File Already in Use".
Resolution This is a Windows NT permissions problem. The account that is accessing the page
doesn't have sufficient permissions to lock the database. The account would be either
the anonymous account (by default the IUSR_<machinename>) or a specific user
account if the page has been secured for authenticated access.
For further details about this error, please refer to the following Microsoft knowledge
base article
http://support.microsoft.com/support/kb/articles/Q174/9/43.ASP"
Summary If you create a login page and try to login, the page returns you to the logout button
instead of the required next page.
Symptoms Login problems usually result from one of the following:
1. The user_id in your user table is not a numeric or autoincrement field
2. Wrong fields are assigned in the security section of CodeCharge.
3. You used a reserved keyword when naming your database table or field, for
example:
Resolution 1. Verify that the key field in your user table is a autoincrement, numeric field
2. Verify that in Site Properties, Security tab, you select the key field in your user
table as the Primary Key. You should select a numeric, autoincrement field as
Primary Key and alphanumeric/text fields for login and password.
3. Do not use reserved words like user, password, month, date, etc. when naming
your fields or tables. These words are reserved keywords in Visual Basic & ASP,
and should not be used in database naming.
Summary When you try to view a php page, you get the error :
"open(temp\/sess_1de7095ab2e3a5ab132abc64c6fccc1b, O_RDWR) failed".
Symptoms This means that PHP tried to store session information in a directory that does not
exist.
Resolution To rectify the problem, you need to set the value of the session_save_path argument
in the php.ini file to a valid directory. The php.ini file is usually located in your
machines system folder or the folder in which php is installed. Open this file and set
its value to something like:
session_save_path = c:/windows/temp
Summary Error: Invalid use of Null Code: 94
Symptoms You get the error message "Invalid use of Null Code: 94" when you try to generate
pages in CodeCharge
Resolution to overcome this problem,try the following solutions:
1. Upgrade Microsoft Internet Explorer to verion 5.5+
2. Install the latest version of the Microsoft Data Access Components (MDAC 2.6)
from http://www.microsoft.com/data/download_260rtm.htm
Summary
Symptoms My database contains a field which holds raw HTML content. How do I display this
content using CodeCharge?
Resolution You can use a field of type Label or URL to output raw HTML. To specify the field
as containing raw HTML, open the field's property window and select the 'HTML'
checkbox.
Summary Update, Delete Buttons donot appear in a record form even though you have
specified that they should be included.
Symptoms You have a record form for which you have specified that all the buttons should be
included [Insert, Update, Delete, Cancel]. However, when you generate the form and
view it, only the 'Insert' and 'Cancel' buttons show.
Resolution The buttons in a 'Record' form are set to appear selectively. By this, the 'Update',
'Delete' and 'Cancel' buttons will only appear if there is some data in the form fields.
This is to say that if you retrieve information from a database or pass the information
to the form using a different method, then the three buttons mentioned above will be
visible. If you think about it, this is logical since it would be moot to have the 'Update'
and 'Delete' buttons and yet not have any data to manipulate. Conversely, if the fields
in your 'Record' form have no data, then only the 'Insert' and 'Cancel' buttons are
shown.
Note that you can still override this behavior by writing your own 'Custom Show'
event for the form.
Summary Norton AntiVirus prevents CodeCharge and/or ASP programs from running
Symptoms When you run CodeCharge, Norton AntiVirus displays the folowing message:
Alert
File: Program
Object: FileSystemObject (FileSystem Object)
Activity: OpenTextFile
Action:
1) Stop this script (recommended)
Resolution 2) Allow this activity once CodeCharge makes extensive use of JavaScripts, which Norton AntiVirus detects
3) Allow the entire script once and prevents from running.
Summary Sending Email
Symptoms How do you send email using the contents of a form and/or database.
Resolution Email sending functionality is dependent on the language you are using as well as the
database server that you use to server your pages. The TellAFriend example
application which comes bundled with CodeCharge contain code which demonstrates
how to implement email functionality. Refer to the Readme.txt file in the example
folder for a listing of code in ASP, Cold Fusion, JSP, Perl and PHP.
Summary
Symptoms How can I capture the identity of the currently logged in user?
Resolution Under the inbuilt CodeCharge login / authentication system, when a user successfully
logs in to your website, a session variable called "UserID" is set which contains the
primary key value that uniquely identifies the user. Later on in the website, you can
capture this session variable if you need to know further details about the user or use
the value in a another form.
To capture the "UserID" session variable, add an input parameter to the form in
question and make sure that the variable name is 'UserID'. If you are using a case
sensitive language such as PHP, make sure that the name appears exactly as shown.
For the Type of the input parameter, select 'Session' as opposed to "Param" so that
CodeCharge knows that it is dealing with a session variable and not a form or URL
variable which would be dealt with differently.
Summary
Symptoms Can I use images as field captions?
Resolution Normally, the caption of a form field contains text which describes the use of the
field. However, you can enter HTML code into the 'Caption' of a field. For instance,
if you want an image to be displayed instead of plain text, you can enter HTML code
like that shown below into the field caption:
<img src = './images/my_image.jpg'>
Summary
Symptoms What are the Header and Footer page for.
Resolution When you add a page to your project and designate it as a Header or a Footer page,
the content of that page will appear at the top or bottom of every other page in you
project respectively. The Header and Footer page are usually used to add
navigational content that applies to the entire site.
A thing to note about Header and Footer pages is that you can't add any event code
to these pages.
Summary
Symptoms Can I edit the generated html templates to change the look of the page?
Resolution If your language of choice generates HTML template files, you can import this into a
HTML editor and edit them to suit your needs. However, in the process of editing the
HTML templates, be careful not to change any of the text that is enclosed is curly
braces {Example}. This text acts a a placeholder to mark where dynamic content will
be included. After the script files retrieve data from the database, they use these
placeholders to place the retrieved data in its appropriate location.
When you open HTML files in some editors (Microsoft Frontpage Express for
example), the editor strips the file of the unknown tag. This will potentially make the
file unusable so such editors should be avoided.
Summary Checkbox fields don't pass the values that you have assigned them to pass.
Symptoms When you add a checkbox field to a form in CodeCharge, you have the option of
specifying the value that will be passed when the checkbox is checked and another to
be passed when it is not checked. For instance, you could have '1' for the checked
state and '0' for te unchecked state.
However, a problem arises such that when you submit the form, the necessary value
is not submitted to the database in which case the field remains empty or generates a
database error. In like manner, if the form submission fails (perhaps the user failed to
enter a require field) then the value of the checkbox is not set to whatever it was
prior to the form submission.
Resolution This issue is due to the design of HTML. When a checkbox is checked, HTML
always submits the value of the form as 'on' and conversely, the value is submitted as
'off' if the checkbox is not checked. The easiest way to accomodate this nuance is to
set the corresponding values in CodeCharge to 'on' and 'off' and similarly use these
values in the database.
However, if you have to use other values such as 'yes'/'no' or '1'/'0', you can add
custom code to catpure the value of the checkbox and convert it to your desired
value.
For instance, if in CodeCharge and the underlying database you have specified the
value of the checkbox to be '1' and '0' for the checked and unchecked states
respectively, then you can use the following code to correctly set the value of the
checkbox when the record is displayed on the screen:
'ASP Code
'Before show event of a grid form
if fldmycheckbox = 1 then
fldmycheckbox = "on"
else
fldmycheckbox = 'off"
end if
Similarly, if you are using a checkbox in a record form to insert new records, you
could use the following code in the 'Before Insert' events to change the value of the
checkbox to what the database requires, in this case '1' and '0'.
'ASP Code
'Before Insert event of a record form
if fldmycheckbox = "on" then
fldmycheckbox = 1
else
fldmycheckbox = 0
end if
Another work around which is perhaps easier to implement and more hustle free is to
use a listbox instead of a checkbox. You can set the values of the listbox options to
whatever you want them to be and they will be read and submitted without any
problem.
Summary Unable to activate CodeCharge over the internet.
Symptoms The machine on which I have installed CodeCharge is not connected to the internet
and I need to activate the Software using my valid serial number.
Resolution To activate CodeCharge, you usually enter the serial number in the Activation Screen
and the software will obtain an activation key over the internet. However, if your
machine is not connected to the internet, you can obtain an activation key from
http://codecharge.com/activation/.
Summary Unable to activate CodeCharge with a valid serial number.
Symptoms I have a valid serial number but when I try to activate the software, it says that I
have exceeded my activation limit.
Resolution When you enter a serial number into CodeCharge, the software connects to the
internet and obtains an activation key.
The Following are the rules that govern the activation of CodeCharge:
1. When you buy CodeCharge, you are allowed to install it on two different machines.
2. In the event that your system crashes, is formatted or you acquire a new machine,
you can activate CodeCharge past the 2 initial activations. Our license monitoring
system keeps tab of how many times a serial number has been used to activate
CodeCharge. Any activations required after the initial activations will be dealt with on
a case by case basis. Please contact support at http://support.yessoftware.com is
case you have problems activating your software.
3. Note that once you install CodeCharge on a machine, you can uninstall then
re-install it countless times without needing a new activation key. The only time you
need an activation key is when you have formatted your harddrive, installed a new
harddrive or want to install on a new machine in which you have never installed
CodeCharge before.
For further information to do with licensing and activation, please refer to the license
agreement. This is in the license.txt file in the CodeCharge folder.
Summary
Symptoms I have added a global function to the Modules section of my project. However, when
I attempt to use the function I get an error indicating that the subroutine is undefined.
What is the matter?
Resolution In the Perl language, when you add a global function, you have to call it using the
syntax Common::FunctionName
Summary Encrypting passwords in PHP
Symptoms The built in CodeCharge authentication system does not encrypt any data before
storing it in the database. For added security, you might want to encrypt user
passwords before storing then in the database.
Resolution To encrypt passwords before they are inserted into the database, use a 'Before
Insert' event to encrypt the data. i.e:
//Encrypt values stored in the password field
$fldPassword = md5($fldPassword);
Note that the PHP encrypt functions generates a one-way hash and hence cannot be
decrypted. This means that when a user enters their saved password for
authentication, you will have to use a 'custom login' event to convert their entered
password into an encrypted hash and then check it against the database value. i.e
//custom login code
$sLogin = get_param("Login");
$sPassword = md5(get_param("Password"));
$db->query("SELECT member_id,member_level FROM members WHERE
member_login =" . tosql($sLogin, "Text") . " AND member_password=" .
tosql($sPassword, "Text"));
if($db->next_record())
{
// Login and password passed
set_session("UserID", $db->f("member_id"));
set_session("UserRights", $db->f("member_level"));
$sPage = get_param("ret_page");
if (strlen($sPage))
header("Location: " . $sPage);
else
header("Location: myRecipientPage.php");
}
else
{
$sLoginErr = "Login or Password is incorrect.";
}
$tpl->parse("FormLogin", false);
where 'myRecipientPage.php' should be replaced with the page where the user
should be directed to after logging in and 'FormLogin' should be replaced with the
name you assigned to the Login form. i.e. if your login form is called 'MyLogin' then
'FormLogin' would change to 'FormMyLogin'
Summary All the pages created using the trial version of CodeCharge have a footer "This
dynamic site was generated with CodeCharge"
Symptoms All the pages created using the trial version of CodeCharge have a footer "This
dynamic site was generated with CodeCharge" which appears at the bottom of the
page with a link to the CodeCharge website.
Resolution Once you enter a valid serial number and activate CodeCharge, then the footer will
no longer appear in the generated pages.
Summary Extending the Trial Period
Symptoms My 20 day CodeCharge trial period has expired and i have not yet finished evaluating
the software. Could you please extend the trial period for me?
Resolution Once the trial period has expired, there is no way of extending the trial period save
for installing a valid serial number. If you have another machine available, you could
install the software on it and have another 2o day trial period.
Summary What is the difference between CodeCharge Standard and Professional Versions?
Symptoms Currently, there is no difference in the functinality of the software, only in the support,
upgrade plans and examples.
The Professional version includes:
- 1 year priority support
- 2 years of free software upgrades, including the future professional version(s).
- CodeCharge project file (.ccs) for this Support System
In several months we will be also releasing version 2.0 of CodeCharge, where
Professional version may include more features and it will cost more, unless you
purchase the upgrade plan we now offer.
Resolution Currently, there is no difference in the functionality of the software, only in the
support, upgrade plans and examples.
The Professional version includes:
- 1 year priority support
- 2 years of free software upgrades, including the future professional version(s).
- CodeCharge project file (.ccs) for this Support System
In several months we will be also releasing version 2.0 of CodeCharge the
Professional version of which may include more features and cost more unless you purchase the upgrade plan we now offer.
Summary You want your record form to insert data into more that one table.
Symptoms Be default, when you add or edit data using a record form, only the table which is
selected in the 'Table' field of the form is affected. However, there arises situations
whereby you want the change to be propagated to other database tables.
Resolution You can use custom event code to capture and add data to other tables. You would
place the code in an event such as 'After Insert' as follows:
ASP Code:
//Create the SQL statement
sSQL = "insert into users (name,password)values (" .tosql(fldname1, "Text") . "," .
tosql(fldname2, "Text") . ")";
//Execute the SQL statement
cn.execute(sSQL);
PHP Code:
//Create the SQL statement
$sSQL = "insert into users (name,password)values (" .tosql($fldname1, "Text") . "," .
tosql($fldname2, "Text") . ")";
//Execute the SQL statement
$db->query($sSQL);
Summary
Symptoms By default, when you conduct a search in a page built using CodeCharge, the SQL
that us used to search for the records uses the 'AND' operator when multiple search
fields exist. For instance, if you are search by 'Name', 'Age' and 'ZipCode', the where
clause of the SQL statement will appear like this to the database:
where Name = 'Julie' AND Age = 24 AND ZipCode = 34298
The main thing to note is that the 'AND' operator is used throughout the where
clause. However, at times you might want to search using the 'OR' operator or a
combination of 'AND' and 'OR' operators.
Resolution If you simply want to replace all the 'AND' operators with the 'OR' operators, you
can place the following code in the open event of the form which is to display the
results:
sWhere = replace (sWhere, "and", "or")
If you want to use a mixture of 'AND' and 'OR' operators you could:
1. re-write the sWhere variable in its entirety.
2. use the reaplce() function in conjuction with other string manipulating functions to
locate and replace specific occurences of the operators.