win32::sqlserver not able to sql_insert

Discussion in 'Perl Misc' started by Digger, Aug 29, 2007.

  1. Digger

    Digger Guest

    Hi,
    I hope that anybody have info on this, i've install and have
    win32::sqlserver working properly.
    I'm able to retrieve data from my database with the select statement.

    My problem is with sql_insert here my code:

    my $table = "icon";
    #my %values=("iconID"=>'3',"link"=>"something");
    #my %values=("iconID"=>3,"link"=>"something");
    #my %values=("iconID"=>"3","link","something");
    #my %values=("iconID",3,"link","something");
    my %values=("iconID","3","link","somethingElse");

    $sqlsrv->sql_insert($table,\%values);

    Table is call icon, iconID is a primary key and an integer, link is a
    varchar.

    Here the error I get all the time:
    SQL Server message 515, Severity 16, State 2, Server WEB-T-
    SQL1\DVSQBQL
    Line 1
    Cannot insert the value NULL into column 'iconid', table
    'master.dbo.Icon'; column does not allow nulls. INSERT fails.
    1> EXEC sp_executesql N'INSERT icon (iconID, link)
    2> VALUES (@P1, @P2)',
    3> N'@P1 int, @P2 varchar(13)',
    4> @P1 = NULL, @P2 = 'somethingElse'
    The statement has been terminated.

    It look like it doesn't like my value for IconID, what's missing...
    take me out of my misery.

    Thx,

    Michel
     
    Digger, Aug 29, 2007
    #1
    1. Advertising

  2. Digger

    Ben Morrow Guest

    Quoth Digger <>:
    > Hi,
    > I hope that anybody have info on this, i've install and have
    > win32::sqlserver working properly.
    > I'm able to retrieve data from my database with the select statement.
    >
    > My problem is with sql_insert here my code:
    >
    > my $table = "icon";
    > #my %values=("iconID"=>'3',"link"=>"something");
    > #my %values=("iconID"=>3,"link"=>"something");
    > #my %values=("iconID"=>"3","link","something");
    > #my %values=("iconID",3,"link","something");
    > my %values=("iconID","3","link","somethingElse");
    >
    > $sqlsrv->sql_insert($table,\%values);
    >
    > Table is call icon, iconID is a primary key and an integer, link is a
    > varchar.
    >
    > Here the error I get all the time:
    > SQL Server message 515, Severity 16, State 2, Server WEB-T-
    > SQL1\DVSQBQL
    > Line 1
    > Cannot insert the value NULL into column 'iconid', table
    > 'master.dbo.Icon'; column does not allow nulls. INSERT fails.
    > 1> EXEC sp_executesql N'INSERT icon (iconID, link)
    > 2> VALUES (@P1, @P2)',
    > 3> N'@P1 int, @P2 varchar(13)',
    > 4> @P1 = NULL, @P2 = 'somethingElse'
    > The statement has been terminated.
    >
    > It look like it doesn't like my value for IconID, what's missing...
    > take me out of my misery.


    Type int, value NULL seems to be what Win32::SqlServer inserts when it
    doesn't recognise the column name. Since SQL Server seems to think the
    column is called 'iconid', not 'iconID', perhaps you should try that.

    Is there a good reason you're not using DBI? While it may not support so
    much of the SQL-Server-specific API, it's probably better tested.

    Ben
     
    Ben Morrow, Aug 30, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. luis valencia

    Dts works from SqlServer but not from ASP.net

    luis valencia, Apr 19, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,460
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Apr 19, 2005
  2. yoshitha

    not able to connect to sqlserver

    yoshitha, Jan 5, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    433
    yoshitha
    Jan 5, 2006
  3. =?Utf-8?B?SmVmZnJleQ==?=

    Upgrading ASP w/SQLserver 2000 to ASP.NET w/ SQLserver 2005

    =?Utf-8?B?SmVmZnJleQ==?=, Apr 6, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    482
    sloan
    Apr 27, 2007
  4. sed_y
    Replies:
    0
    Views:
    1,024
    sed_y
    Feb 15, 2012
  5. Jim Roberts
    Replies:
    7
    Views:
    244
    Bart Lateur
    Jan 4, 2006
Loading...

Share This Page