[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

07S01 Invalid use of default parameter

Chuck Hipschman

3/15/2002 8:41:00 PM

I don't understand what this error is trying to tell me.
I'm using the ODBC.Net provider because my production db
only has ODBC drivers available. But for development,
I'm using SQL Server 2000. I DTS'd the data in. This
database has weird things, like char columns not null, no
default specified, that must be blank filled.

So, please interpret this error message if possible.
What should I be looking for?
3 Answers

(Steven Bras [MS])

3/15/2002 10:22:00 PM

0

HariNam Singh

3/18/2002 8:00:00 PM

0

I have the same error. SQL runs fine in the query analyzer. ODBC.NET rejects
it with

ERROR [07S01] [Microsoft][ODBC SQL Server Driver]Invalid use of default
parameter

Trace shows that the SQL doesn't seem to reach the database.

table structure:
CREATE TABLE ei_client_options
(
id int NOT NULL PRIMARY KEY IDENTITY
, clientnumber varchar(255) NOT NULL
, taskmapping int NOT NULL
, deliverymethod int NOT NULL
, smtphost varchar(255)
, emailto varchar(255)
, emailreply varchar(255)
, emailcc varchar(255)
, emailsubject varchar(255)
, encrypted bit
, aeskey varchar(255)
, aesiv varchar(255)
, transporthost varchar(255)
, transportport int
, created datetime NOT NULL
, createdby varchar(20) NOT NULL
, updated datetime NOT NULL
, updatedby varchar(20) NOT NULL
)


SQL
private const string SQL_INSERT = @"INSERT INTO ei_client_options
(clientnumber, taskmapping, deliverymethod, smtphost, emailto, emailreply,
emailcc, emailsubject, encrypted, aeskey, aesiv, transporthost,
transportport, created, createdby, updated, updatedby) VALUES (?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, getdate(), ?, getdate(), ?)";

Code
public void Insert(string currentUser) {
OdbcCommand command = Config.CreateOdbcCommand(SQL_INSERT);
command.Parameters.Add(new OdbcParameter("a", ClientNumber));
command.Parameters.Add(new OdbcParameter("b", TaskMapping));
command.Parameters.Add(new OdbcParameter("c", DeliveryMethod));
command.Parameters.Add(new OdbcParameter("d", SmtpHost));
command.Parameters.Add(new OdbcParameter("e", EmailTo));
command.Parameters.Add(new OdbcParameter("f", EmailReply));
command.Parameters.Add(new OdbcParameter("g", EmailCC));
command.Parameters.Add(new OdbcParameter("h", EmailSubject));
command.Parameters.Add(new OdbcParameter("i", Encrypted));
command.Parameters.Add(new OdbcParameter("j", AesKey));
command.Parameters.Add(new OdbcParameter("k", AesIV));
command.Parameters.Add(new OdbcParameter("l", TransportHost));
command.Parameters.Add(new OdbcParameter("m", TransportPort));
command.Parameters.Add(new OdbcParameter("n", currentUser));
command.Parameters.Add(new OdbcParameter("o", currentUser));
Debug.WriteLine(command.CommandText);
command.ExecuteNonQuery();
command.Dispose();
}

Besides, the code above shows that I don't know how to use the odbc
parameter names properly. Tips on that would be appreciated as well.



"Steven Bras [MS]" <stevenbr@online.microsoft.com> wrote in message
news:3dDltdGzBHA.1336@cpmsftngxa09...
> Post what you do that causes the error and I'll try to assist.
>
> Steven Bras, MCSD
> Microsoft Developer Support/Visual Basic WebData
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
> Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.co....


HariNam Singh

3/18/2002 8:31:00 PM

0

Problem solved. One of the values that was passed was null, while it was a
required field. It seems like a bad error message. Still looking for help on
using named parameters.


"HariNam Singh" <hsingh@elite.com> wrote in message
news:OlfMEHrzBHA.352@tkmsftngp03...
> I have the same error. SQL runs fine in the query analyzer. ODBC.NET
rejects
> it with
>
> ERROR [07S01] [Microsoft][ODBC SQL Server Driver]Invalid use of default
> parameter
>
> Trace shows that the SQL doesn't seem to reach the database.
>
> table structure:
> CREATE TABLE ei_client_options
> (
> id int NOT NULL PRIMARY KEY IDENTITY
> , clientnumber varchar(255) NOT NULL
> , taskmapping int NOT NULL
> , deliverymethod int NOT NULL
> , smtphost varchar(255)
> , emailto varchar(255)
> , emailreply varchar(255)
> , emailcc varchar(255)
> , emailsubject varchar(255)
> , encrypted bit
> , aeskey varchar(255)
> , aesiv varchar(255)
> , transporthost varchar(255)
> , transportport int
> , created datetime NOT NULL
> , createdby varchar(20) NOT NULL
> , updated datetime NOT NULL
> , updatedby varchar(20) NOT NULL
> )
>
>
> SQL
> private const string SQL_INSERT = @"INSERT INTO ei_client_options
> (clientnumber, taskmapping, deliverymethod, smtphost, emailto, emailreply,
> emailcc, emailsubject, encrypted, aeskey, aesiv, transporthost,
> transportport, created, createdby, updated, updatedby) VALUES (?, ?, ?, ?,
> ?, ?, ?, ?, ?, ?, ?, ?, ?, getdate(), ?, getdate(), ?)";
>
> Code
> public void Insert(string currentUser) {
> OdbcCommand command = Config.CreateOdbcCommand(SQL_INSERT);
> command.Parameters.Add(new OdbcParameter("a", ClientNumber));
> command.Parameters.Add(new OdbcParameter("b", TaskMapping));
> command.Parameters.Add(new OdbcParameter("c", DeliveryMethod));
> command.Parameters.Add(new OdbcParameter("d", SmtpHost));
> command.Parameters.Add(new OdbcParameter("e", EmailTo));
> command.Parameters.Add(new OdbcParameter("f", EmailReply));
> command.Parameters.Add(new OdbcParameter("g", EmailCC));
> command.Parameters.Add(new OdbcParameter("h", EmailSubject));
> command.Parameters.Add(new OdbcParameter("i", Encrypted));
> command.Parameters.Add(new OdbcParameter("j", AesKey));
> command.Parameters.Add(new OdbcParameter("k", AesIV));
> command.Parameters.Add(new OdbcParameter("l", TransportHost));
> command.Parameters.Add(new OdbcParameter("m", TransportPort));
> command.Parameters.Add(new OdbcParameter("n", currentUser));
> command.Parameters.Add(new OdbcParameter("o", currentUser));
> Debug.WriteLine(command.CommandText);
> command.ExecuteNonQuery();
> command.Dispose();
> }
>
> Besides, the code above shows that I don't know how to use the odbc
> parameter names properly. Tips on that would be appreciated as well.
>
>
>
> "Steven Bras [MS]" <stevenbr@online.microsoft.com> wrote in message
> news:3dDltdGzBHA.1336@cpmsftngxa09...
> > Post what you do that causes the error and I'll try to assist.
> >
> > Steven Bras, MCSD
> > Microsoft Developer Support/Visual Basic WebData
> >
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> >
> > Are you secure? For information about the Microsoft Strategic Technology
> > Protection Program and to order your FREE Security Tool Kit, please
visit
> > http://www.microsoft.co....
>
>