Win32::ODBC - can get info from Access97 database, but can't modify
Mart
marts-spam-me-not- na iname.com
Pondělí Březen 5 21:21:31 MET 2001
Hi Denis,
I'm no SQL programmer, but are you trying to select data from your database
with a new userid (line 5) and then update it with the same data (line9)?
Mart
Denis Hudon <mortarandpestle na hotmail.com> wrote in message
news:nTRo6.188087$v.16963367 na typhoon.nyroc.rr.com...
> I'm trying to use the perl Win32::ODBC module to manipulate my Microsoft
> Access 97 database. I can generate a connection to the database, and can
> get information from it using the Sql() function, but cannot modify it
using
> the Sql() function. In the sample code below, lines 5 through 7
> successfully accesses the database, assigning the appropriate value to
> $ExistUserID. Lines 9 through 10, however, which seem to execute without
> error when I run the program, do not actually modify the database. I'm
new
> to both perl and SQL, but I believe that this second section of code
should
> add a new row to the table "Users" in which the column "UserID" has a
value
> equal to $NewUserID. What am I doing wrong? Is it even a perl problem,
or
> do I have something improperly configured in my ODBC control panel or in
> Microsoft Access? Or is my SQL code just no good? Thanks for taking the
> time to read this.
>
> 1 use Win32::ODBC;
> 2
> 3 $ModifyDatabase = new Win32::ODBC("NorthwayExchange");
> 4
> 5 $ModifyDatabase->Sql("SELECT UserID FROM Users WHERE UserID =
> '$NewUserID'");
> 6 $ModifyDatabase->FetchRow();
> 7 $ExistUserID = $ModifyDatabase->Data("UserID");
> 8
> 9 $ModifyDatabase->Sql("INSERT INTO Users (UserID) VALUES
($NewUserID)");
> 10 $ModifyDatabase->Close();
>
>
Další informace o konferenci Perl