| Subject |
Re: ADOdatabase not working in signup.prg |
| From |
Gaetano <gaetanodd@hotmail.com> |
| Date |
Mon, 24 Aug 2020 16:48:20 +1000 |
| Newsgroups |
dbase.getting-started |
forget about the update, it was the quotes that were causing the error...
On 24/08/2020 16:45, Gaetano wrote:
> As I was trying to create the same connection in a datamodule using a
> string for the connection, I got a similar error: "Test connection
> failed because of an error in initializing provider.[Microsoft][ODBC
> driver Manager] Data source name not found and no default driver specified"
>
> Hopefully that helps narrowing down the reason for the failure.
>
> Here is the connection string with sensitive elements <replaced>...
>
> "Driver=MySQL ODBC 8.0 ANSI Driver;SERVER=<serverIPaddress>;UID=<user
> ID>;PWD=<password>;DATABASE=<database name on the server>;PORT=3306"
>
> Cheers,
> Gaetano.
>
> When entering connection string and testing the connection, I get the
> error "
>
> On 24/08/2020 15:47, Gaetano wrote:
>>
>> Hi there,
>>
>> I'm going through the web tutorials and was customizing the PRG file
>> generated by the wizard.
>>
>> I am trying to use ADO to connect to a MySQL database. THe first step
>> was to connect and create the attendees table using the following code:
>>
>> d = new adodatabase()
>> d.connectionString = "my connection string"
>> d.active = true
>>
>>
>> try
>> cStr = "CREATE TABLE attendees ( "
>> cStr += " FirstName CHAR(15) NOT NULL,"
>> cStr += " LastName CHAR(20) NOT NULL,"
>> cStr += " Address CHAR(35) NOT NULL,"
>> cStr += " City CHAR(20) NOT NULL,"
>> cStr += " State CHAR(2) NOT NULL,"
>> cStr += " Zip CHAR(10) NOT NULL,"
>> cStr += " eMailAddress CHAR(80) NOT NULL,"
>> cStr += " eMailSentDate CHAR(8) NOT NULL,"
>> cStr += " PRIMARY KEY USING BTREE (FirstName))"
>> d.executeSQL(cStr)
>> catch(exception e)
>> endtry
>>
>> That code works perfectly when in a standalone PRG file, the table is
>> created on the server.
>>
>> However, when I insert it in the signup.PRG file, it causes a database
>> engine error while making the database connection active.
>>
>> Here is how it is inserted in the PRG file:
>>
>> *****Note - I concatenate the error messages so they all appear on a
>> single page
>>
>>
>> if (not oCGI.isKey("ATTENDEES1*@eMailAddress")) or
>> empty(oCGI["ATTENDEES1*@eMailAddress"])
>>
>> cSorry+="<B>eMail Address</B> is required!<br>"
>>
>> endif
>>
>> **** note: once all the checks are done for any empty fields, I check
>> for the length of the cSorry string to determine if there were any
>> missing fields, and if not, I establish the connection and try to
>> create the table. The table is not being created on the server when
>> the code is inserted in this SIGNUP.PRG file
>>
>>
>> if len(cSorry)>0
>> oCGI.SorryPage(cSorry)
>> release cSorry
>> else
>>
>> d = new adodatabase()
>> d.connectionString = "my connection string"
>> d.active = true <----this is the offending line
>>
>>
>> try
>> cStr = "CREATE TABLE attendees ( "
>> cStr += " FirstName CHAR(15) NOT NULL,"
>> cStr += " LastName CHAR(20) NOT NULL,"
>> cStr += " Address CHAR(35) NOT NULL,"
>> cStr += " City CHAR(20) NOT NULL,"
>> cStr += " State CHAR(2) NOT NULL,"
>> cStr += " Zip CHAR(10) NOT NULL,"
>> cStr += " eMailAddress CHAR(80) NOT NULL,"
>> cStr += " eMailSentDate CHAR(8) NOT NULL,"
>> cStr += " PRIMARY KEY USING BTREE (FirstName))"
>> d.executeSQL(cStr)
>> catch(exception e)
>> endtry
>>
>> ////// Open Query or dataModule
>> SET PROCEDURE TO "attendees.dmd" ADDITIVE
>> dMod = new attendeesDataModule()
>>
>> Any idea why this is not working?
>>
>> Cheers,
>> Gaetano.
>
|
|