Re: SQL Server Parameters



I set default values in the SP and that made it process fine. However, I
don't want to do that as there aren't "default" values. The Modified row of
the DataSet doesn't show any values for the fields that are not bound to any
controls on the form. These are the fields that are giving me the problems.

Let's say the DataSet has Customer_ID, CustomerName, Address, DumbField and
the form only has controls for Customer_ID, CustomerName and Address. When I
pass this DataSet back to the SP with my DataAdapter, DumbField is passed in
as a Null value. I understand what SQL Server is doing and it is doing as
expected. I am just unsure of how to best submit this information from my
application. I realize that I could just create a New SP that only takes in
Parameters for the fields that I show on the form, but since 99% of the
fields are in use on the form, I just figured it was easier to make a generic
Insert and Update SP that takes in all of the fields in the table as
parameters.

Is this what others have experienced with DataSets?

Hopefully this will help to explain the situation.

PS - There is only one row in this update, so I know exactly where this is
coming from.


"W.G. Ryan - MVP" wrote:

> Aspnot - if I understand your problem correctly, it soudns like your update
> statement is the problem. When you say that it's being passed as default,
> not as the dataset field, I'm not sure I follow you based on your second
> statement about defaults. If you have a parameter specified, but it's null
> (not DbNull.Value, but null) nad you don't have a default value set up in
> the procedure or t-sql block, then you'll get this error. Similarly, if you
> have a missing param or misspelled it, same thing. The latter doesn't
> appear to be the case, but it sounds like you have a null value. Trap
> RowUpdating
> (http://msdn2.microsoft.com/en-us/library/t8k4cyxy(en-US,VS.80).aspx) for
> isntance on your adapter and do a
> Debug.Assert(ValueForTheColumnThatMapstoMyParameter != null, "Whatever
> Column has a null value"); // You may want to stick an identifier from the
> key or another value that will help you trap the specific row down)
>
> Also, i may have gotten ahead of myself... Are any rows updating or does
> this fail immediately? You may just be missing the parameter/ misspelled
> it, or missing the columnmapping in your update statement. If you would
> post the Update code, that might show the problem.
>
> HTH,
>
> Bill
> "Aspnot" <NOSPAM_Aspnot_NOSPAM@xxxxxxxxx> wrote in message
> news:49487383-181B-444A-B0D7-00FA9CE50F5D@xxxxxxxxxxxxxxxx
> >I have a typed DataSet with say 50 fields in it. On the form, I only show
> >40.
> > I have a stored procedure that takes in all 50 parameters. When I call
> > SqlDataAdapter.Update(ds.Tables(0).GetChanges(DataRowState.Modified)), I
> > get
> > a SQL error back that Procedure XYZ is expecting Parameter '@myParameter'
> > which was not supplied.
> >
> > In looking at Profiler, I can see that this parameter is being passed to
> > SQL
> > Server as Default, not as the value that the field has in the Original
> > DataSet.
> >
> > Any suggestions?
> >
> > - I know that I can set the Default values inside of SQL Server, but that
> > isn't going to work for this situation.
> >
> > Thanks in advance
>
>
>
.



Relevant Pages

  • Re: How to enable Windows Authentication
    ... either your missing something or I am missing something and I ... Windows Local User accounts. ... I remove the comments from the connection string in the web.config I can ... When connecting to SQL Server 2005, this failure may be caused by the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Limit of 150 rows in a combobox?
    ... I can't find an answer to this in the newgroup postings, ... datasource is a SQL Server stored procedure. ... 200 rows when executed on SQL Server. ... Any advice on finding these missing rows would be most ...
    (microsoft.public.access.forms)
  • Re: Error 22272: Cannot load the DLL xpstar.dll...
    ... I would look for MSVCR71.DLL in SYSTEM32. ... I believe that if an entire DLL was missing, ... Reinstall the SQL Server tools? ...
    (comp.databases.ms-sqlserver)
  • Re: Recreate table - including new columns
    ... You are not missing anything. ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. ... > B. Recreate destination table > C. Pump in the data ... > The problem is that my DTS job ignores any new fields. ...
    (microsoft.public.sqlserver.dts)
  • Sybase error -5702 and -1
    ... sql error in the C application is 5702 and connection terminates. ... The SQL Server is terminating this process. ... I don't have access to server m/c. ...
    (comp.databases.sybase)