ADO.NET :: How To Test If The Value Is Null
Dec 28, 2010
I'm using the following code to retrieve a value from a SqlDataSource:
[Code]....
The code works fine as long as the variable has a value. But if it's null, then I get errors. How can I test if the value is null?
View 5 Replies
Similar Messages:
Mar 11, 2011
I've created a WCF Service that Performs Insert User, What it does is, it'l get user name, age,gender,address,phone no and inserts these values into SQL database.
Problem is :
These things are working fine, if i give all the values in the WCF Test Client, It's Not working when i din't enter value for Address and click "Invoke" Button, It's throwing an Exception Procedure or Function "Insert_User" Expects
ADDRESS' Which was not supplied. I've created the SQL table Which allow Null Values for Address.
I've did the same Operaion in WebService also, there it's working fine, if i din't enter any value for tha Allow Null Colums, it's accepting the Null value and inserting into Database.
Why this Problem comes in WCF Test client, Guide me to Get rid of this Problem.
View 1 Replies
Jun 30, 2010
I am using httpcontext.Current in one my action method and i created the ms test method for testing this action and also i created the Mock object for httpcontect,but when i am trying to run the MS test script i am getting null reference exception from the line which i am using httpcontext.current in the action method.
View 1 Replies
Mar 13, 2011
var query = from emp in dbEmp.Employees join dept in dbEmp.Departments on emp.DeptID equals dept.DeptID where dept.DepartmentName.Contains(this.TextBox1.Text) select new { EmpID = emp.EmpID, EmpName = emp.EmpName, Age = emp.Age, Address = emp.Address, DeptName
= dept.DepartmentName };
if (query==null) Label1.Text = "no results match your search";
GridView1.DataSource = query; GridView1.DataBind();
Everything works in the right way, but the label doesn't show the message when query result returns null. The label can show without condition(querry==null). So how to test if a var query result returns nothing?
View 2 Replies
May 15, 2010
i have to do some message exchange with a 3rd party (in a website).When the client posts a page, i start the message exchange. When that doesn't succeed for some reason, i report this to the client by rendering the page with a message.On the background, in a separate thread, i start a process to send abort messages to the 3rd party. I can't do this while the user is waiting for the page to come back, because it might take a few minutes.But in a test project, the test ends when the message to the 3rd party is sent, and after the new thread is started. But it seems that the new thread also ends, when the test is done.
Is that normal behaviour?I do start the thread in a new class with a reference to 2 objects from the class which tries to send the message in the first place, may that be a problem?EDIT: it keeps running when the whole process is started in IIS
View 1 Replies
Mar 24, 2010
I am doing Automated coded ui testing in asp.net 2010 for web application. I am testing site and i need to know how can i create the test which will work with all browsers. Right now i created test in IE 8 but its not working in Firefox. So is there any way i can create one test and will work in all browser.
View 2 Replies
Mar 3, 2011
i have datagrid , data coming from database but data in database as formated , i want to show data wihotu format
below example:
<B> test </B> data base has this type data
but in grid i want to show test not with format,
i am getting same data from database.
View 2 Replies
Dec 6, 2010
I have setup my business object to have a create_date and edit_date members both datetime datatypes. My company want to display the create_date and edit_date fields in a gridview for each transaction. The problem i have is that after insterting a record it will have a valid create_date but no edit_date and when displayed in the gridview it defaults to datetime.minvalue (My default). How on earth do i show an empty field in my gridview for a null datetime field in the database?
I am using similar architecture to the Imar Spaanjaars example of a tiered solution. With a few small tweeks it has worked well for me for ages. I am passing a List<Database> to my object datasource which connects to my gridview.
View 3 Replies
Oct 2, 2010
I have 2 table Table A, Table B.
Table A - Parent Table
ID - Uniqueidentifier not null(PK)
Table B -Child Table
ID - uniqueidentifier null(FK, TableA)
I have a stored procedure to insert data into Table B, but when I tried to insert a null value into column ID of table B, this error came up:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tableB_tableA". The conflict occurred in database "database name", table "table A", column 'ID'.
The statement has been terminated.
The insert statement in asp.net is like so:
sqlcommand.parameter.add(New Sqlparameter("ID", Nothing))
I am guessing adding nothing to the null value column is the problem, but i don't know how to fix it... The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tableB_tableA". The conflict occurred in database "database name", table "table A", column 'ID'.
View 5 Replies
Mar 18, 2010
I have a problem with a SessionVariable. I will explain what is happening:
1. From the default.aspx I send Session["LoginByAdmin"] = "Dummy"; and then redirect to this page where I have the code below. So the Page_Load sees that this Session["LoginByAdmin"] != null and enter this page. This works fine !
2. In the Page_Load, I later fill a ListBox1 with foldernames.
3. With Button1_Click1, I will now delete the choosen Folder in the ListBox1 wich works fine the first time and the ListBox updates the new existing folders in the ListBox. (I have wrapped this inside an updatepanel)
The problems comes now when I try to delete a choosen folder in the ListBox1 the second time in a row. When I select a Folder in the ListBox1 and now Press Button1, I will be redirected to "Default.aspx". This meens that this code is running: (That meens that Session["LoginByAdmin"] == null and I have not set this to null anywhere. This is my big question how this variable can be = null here?
if (Session["LoginByAdmin"] == null)
Response.Redirect("Default.aspx");
break;
[Code]....
View 5 Replies
Feb 24, 2010
I am using dropdownlist in my view page with some values which will display corresponding ID(primary key of other table) in my database.If i leave my dropdownlist blank and save it in database then its showing null parameter error. Can you explain how to use this reference type to overcome this error
View 2 Replies
Nov 6, 2010
i am using the following in a stored procedure.
[code]....
[Code]....Handling NULL...Field not updating when NULL?
View 3 Replies
Jan 5, 2011
In my code behind, I have the following code that I want to insert a null value for a parameter. Instead of doing that, it is adding the word "NULL" to my database. What am I doing wrong?
dsRevealedByCR.UpdateParameters.Add("txtGrantor","Null")
View 5 Replies
May 17, 2010
m getting this error again and again. i m also using the ajax modalpopup extender in my page ..
View 3 Replies
May 13, 2010
My site was woking fine, now i noticed that i get an error "Microsoft JScript runtime error: 'null' is null or not an object" when i checked the view source, i saw the following system generated code
<script type="text/javascript">
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
ValidatorOnLoad();
function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
else {
return true;
}
WebForm_AutoFocus('txtMailAddress');// --> IS THIS RIGHT???? out side the braces???
</script>
</form>
</body>
</HTML>
and a reference to this line below
<IFRAME id="__hifSmartNav" name="__hifSmartNav" style="display:none" src="/m2qa/WebResource.axd?d=fvL5WUdiCo1B4KvdiJfkfg2&t=633546432952161750"></IFRAME>
View 3 Replies
Jan 21, 2010
here is my code for selectiong some records from db table
string strSql = "select * from mtblNBD where SentTo=@SentTo and InternalStatus Is NULL order by DeadLine desc";
SqlCommand com = new SqlCommand(strSql, con);
com.Parameters.Add("@SentTo", SqlDbType.NVarChar, 50).Value = (string)Session["uname"];
here I am using parameters for SenTo field but not for NULL so it is ok... or should I use parameters for this field where value is NULL , if yes then how can I use parameter for this
View 8 Replies
May 5, 2010
i'm a developer with some experience in dotnet 2.0.
i work at the moment with web application and i'd like to find a book or some article about how to test a web application for to know some error that i don't know to do of course :)
is someone knows some good article or book !?
View 6 Replies
Jan 28, 2011
Im trying to write a small web application for forwarding requests to my page to the new pages on my web site. First off im implementing a IHttpHandler and in the ProcessRequest method i simple want to print out the requesting page, my conde looks like this:
public class RedirectHandler : IHttpHandler
{
public bool IsReusable
{
get { return true; }
[code]...
View 1 Replies
Aug 17, 2010
I am trying to run WaitN test using NUnit. The test is taken from the book Pro ASP.NET MVC 2 Frameworkby Steven Sanderson and it's located on page 73-74.The test is just testing a default MVC 2 application and it looks like this:
[Code]....
I can run the test in the NUnit GUI, but it fails, I get this error message:IntegrationTestingExample.WaitNTests.UserAccountTests.DisplaysUserNameInPageHeader:System.Threading.ThreadStateException : The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.This is the stack trace from the NUnit GUI:
at WatiN.Core.IE.CheckThreadApartmentStateIsSTA()
at WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, Boolean createInNewProcess)
at WatiN.Core.IE..ctor()
at IntegrationTestingExample.WaitNTests.UserAccountTests.CreateBrowser() in d:documents and settingsmy documentsvisual studio 2010ProjectsRuneIntegrationTestingExampleIntegrationTestingExample.WaitNTestsUserAccountTests.cs:line 42
at IntegrationTestingExample.WaitNTests.UserAccountTests.DisplaysUserNameInPageHeader() in d:documents and settingsmy documentsvisual studio 2010ProjectsRuneIntegrationTestingExampleIntegrationTestingExample.WaitNTestsUserAccountTests.cs:line 17
WHAT SHALL I DO TO MAKE THE WAITN TEST PASS? AM I DO SOMETHING WRONG? AM I USING THE RIGHT TOOL TO RUN WAITN TESTS?
View 1 Replies
Sep 22, 2010
My question so general, but I think the answer will be specific.
All I want to know is:
Is there a way or steps or mechanism to test the application (web application) in a professional way?
Many times when I finish developing and try my application, testing it with dummy data several times, and when I think every thing is okay and I think I have covered all possible scenarios, I find I forgot important issues, or others tell me they found problems in my application.
How do I overcome this problem, and save my time?
Good links:
[URL]
[URL]
View 7 Replies
Nov 12, 2010
Performance testing best practices for an ap .net application
View 1 Replies
Oct 5, 2010
I have a simple web test. All Web tests concluded in the following method:
[code]....
How can I do this?
MembershipCreateStatus
View 3 Replies
Mar 15, 2011
When I first created the project. Visual studio 2010 gave me an option to create the test project, but I selected "No". Now i want to add teh Test project. Is theor any way, I can add the Test project later.
View 2 Replies
Nov 21, 2010
I'm trying to unit test the MembershipProvider, however I cant figure out how or whether there is any need for unit testing of it...
My business layer:
public interface IAccountService
{
MembershipCreateStatus CreateUser(string userName, string password, string email);
}
public class AccountService : IAccountService
{
private readonly MembershipProvider provider;
public AccountService() : this(null) { }
public AccountService(MembershipProvider providera)
{
this.provider = providera ?? Membership.Provider;
}
public MembershipCreateStatus CreateUser(string userName, string password, string email)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", userName);
if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", password);
if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", email);
MembershipCreateStatus status;
provider.CreateUser(userName, password, email, null, null, true, null, out status);
return status;
}
}
The only examples I've found so far requires a "MockMembershipProvider" with a local database setup... seems quite odd to me.
View 1 Replies
Jan 9, 2011
I want to test that when my form data is posted back to my controllers that the data annotations and the model binding is going to do its job and give the correct model state. After googling for a while I can't find a really good tutorial or article that shows how to do this.
Can anyone point me in the right direction? What is the best practice in this area? I have read that I may need to use moq and MVCContrib but I have not read a tutorial that makes me shout, "Yes, this is the right way to do it!"
View 1 Replies