?
Solved

Help with nullable variables and a webmethod

Posted on 2008-10-29
5
Medium Priority
?
872 Views
Last Modified: 2008-11-07
I have a web methods that is set up like so

public DataSet updateAppRecord(int app_id, string app_acro, string app_name, int? app_type_id, int control_level_id, bool active)

As you can see there is one variable that is "nullable" int?  

It has to be nullable because a value will not ALWAYS be passed though with this...sometimes it will be null

on the back end I call it like so

DataSet ds = almsvc.updateAppRecord(app_id.Value, app_acro, app_name, app_type_id.Value, ctl_level_id.Value, active.Value);

I ahve also tried it like so

DataSet ds = almsvc.updateAppRecord(app_id.Value, app_acro, app_name, app_type_id, ctl_level_id.Value, active.Value);

I have to beleive that the issue is occuring because of the int? for the app_type_id   app_type_id.Value would be the way you woudl normally cast an int? to an int variable....but if it is int? to int? my understanding is you dont need the.Value.     Why do I get a SOAP exception when I try to pass the int? variable to the web service when the web service is asking for an int? variable?



0
Comment
Question by:Prysson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 22834053
at your database design, is this variable declared as nullable? (Allow null)
0
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22834660
int will be automatically converted into int? So that should not be the issue. I dont think DBNull will be converted into integer. Before calling the web method check if the value passed is DBNull
0
 

Author Comment

by:Prysson
ID: 22840069
1. The database allow for null values in all columns.
2. a step through of the code during testing shows that no dbnull values are being passed into the web method.

Whats more..I removed all possibility of null in teh variables by using conversion methods converting null entries into "0" or "false" depending on the variable...so no null are being passed no nulls are being expected and nullas are allowed bythe database...still I am getting the error...I am totally confused now..I cant see any reason why this would be happening.

0
 

Author Comment

by:Prysson
ID: 22840880
Ok I have eliminated the interface and even the web service..the error is occuring in the BLL and DAL layers compiled into a dll.

A method that fills a datatble querying data from the database give a foreign key constraint error...Now this I totally dont understand.  I have revied the datatable and its data..none of the data violates foreign key constraints and the datatable allows nulls for all columns...unless thats it..is it a violation of a foreign key constraint to have a null value?
0
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 1500 total points
ID: 22842941
Foreign key does not allow null values, that should be the issue.
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question