|
Colin Angus Mackay wrote: jon_80 wrote:
Although the code passes through here, the value of getTaskRefSQL is null, is this a bug?
Are you sue that getTaskRefSQL is null. Unless you've missed something out of your code in the sample above there is no way getTaskRefSQL can be null at the point in the code you've said it is.
That's what I thought; I checked again and now it has a value, however before it was reading null in the watch window
Colin Angus Mackay wrote: The result of ExecuteScalar can be one of three things.
1. An object of the type you expect. String in this case
2. a DBNull which means that the value of the column you've selected is null
3. a null which means that the query returned no data. (please check for this rather than use an invalid cast exception)
Explicit conversion was required because implicit conversion is not allowed by the compiler. I think can check for a DBNull using typeof presumably, however, since a value is being returned I'm not sure why the conversion is not working.
Related links:
http://msdn.microsoft.com/en-us/library/58918ffs(VS.71).aspx[^]
Jon
|
|
|
|
|
jon_80 wrote: Explicit conversion was required because implicit conversion is not allowed by the compiler.
I wasn't talking about that.
jon_80 wrote: I think can check for a DBNull using typeof presumably
Try something like:
object rawValue = theSqlCommand.ExecuteScalar();
if (rawValue == DBNull.Value)
{
}
else
{
string actualValue = (string)rawValue;
}
|
|
|
|
|
|
|
You're right I still haven't planned any error handling as yet
Jon
|
|
|
|
|
Hello All,
I want to delete value from cookie
For Example: The Cookie name [myCooke]
The Cookie Contains--------------------------------------------------------------------------------
myCookeLotID1=7amp;LotNo1=003462&LotName1=Lot 7&BuyPrice1=850&StockQuantity1=56
amp;amp;LotID2=5&LotNo2=003859&LotName2=Lot 3&BuyPrice2=154&StockQuantity2=2
localhost/1536149997862429993731246977484829981862*
---------------------------------------------------------------------------------------------------
The question: How i can delete [LotName2=Lot 3] value from this cookie?
please reply me quickly.
Thank you
Best Regards
Abdullah S. Abdelhay
|
|
|
|
|
I am going to assume that the cookie contents arn't exactly as you typed it...because it seems there are a few typos in it. The following should work:
string cookie = "LotID1=7&LotNo1=003462&LotName1=Lot 7&BuyPrice1=850&StockQuantity1=56&LotID2=5&LotNo2=003859&LotName2=Lot 3&BuyPrice2=154&StockQuantity2=2";
string[] values = cookie.Split('&');
string[] newValues = (from cv in values
let eqIdx = cv.IndexOf('=')
let name = cv.Substring(0, eqIdx)
let value = cv.Substring(eqIdx + 1)
where name != "LotName2"
select cv).ToArray();
string newCookie = String.Join("&", newValues);
|
|
|
|
|
in Fact you cannot delete value from a cookie but
you should have to recreate the cookie with the new value as explained by the previous post.
Rama Charan Prasad
"Be happy and Keep smiling.Thats what u want be always.. "
|
|
|
|
|
We cannot delete a cookie actually. But one thing we can do is like, we can set the expiry date of the cookie to prior date, so that the browser will remove the cookie when it access the cookie for the next time, since it is expired.
Expiring the Cookie in Server Side:
if (Request.Cookies["MyCookie"] != null)
{
HttpCookie myCookie = new HttpCookie("MyCookie");
myCookie.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(myCookie);
}
<u>Expiring the Cookie in ClientSide Side:</u>
<script type="text/javascript">
<!--
deleteCookie('MyCookie');
</script>
Please reply on any doubts. Hope this will be usefull for you.
Thanks,
Rajdev KR
|
|
|
|
|
hi all
This is my first question in the forum. i want to ask how to work with excel file independant of version problem in asp.net 2.0 like while reading excel file.?
Nitin
|
|
|
|
|
You need to install Excel on the web server on which you are developing asp.net application, so just install the latest version - 2007, and its backward compitable. so it can handle all the files of ,whatever version.
|
|
|
|
|
Hi,
Can I please hear your views in using the MVP and MVC pattern? I want to use the web client software factory or ASP.NET MVC, but not sure which way to go. The website is a rather huge website. I was thinking to go woth the WCSF for now, and wait till ASP.NET MVC is in a more stable condition and then convert?
I have ready many articled on MVP and MVC, but still there is a confusion as to which one to use. WCSF makes use of DLLs which in my mind is faster, in the ASP.NET samples that I have see the code is just placed in folders, so because they are not already DLLs, wont it take longer to run?
Regards
Brendan
|
|
|
|
|
I have made many (over 50) asp.net applications both large and small. I have never seen the value in MVC or MVP.
I do separate the presentation and data layer and I implement themes. I use a master page and base page whenever possible and put all styling in the css file(s) in a theme. This makes it easy to change the presentation.
Adhering to a specific framework just seems to make more work without providing much benefit. The frameworks are good for developers who are less experienced with ASP.Net but if you know what you are doing than there is no need to constrict your development. Sometimes you just want to code a bit differently.
As for dlls, if you do not compile your website and just place code files IIS will compile the page the first time it is requested. The only advantage to compiling a web site is that the first user doesn't have to wait for it to compile.
I didn't get any requirements for the signature
|
|
|
|
|
|
|
I would suggest by reading one of the articles here http//www.asp.net.
|
|
|
|
|
Hi all,
I have deployed one application on server reside in US,now problem is that when any person using this site from india and he save some data in current date but my application is deployed on US Server so it takes system date of that server which is about one day b4 in some cases and when user search that data in this date he could not get it,is there any way to remove this complexity
N!dh!
|
|
|
|
|
Hi Nidhi,
One probable solution for this is to change the default value of date column from
GetDate()to GetUTCDate() in table defination. This way it will store the date values according to UTC instead of local time zone specific date.
dnpro
"Very bad programmer"
|
|
|
|
|
Hi,
I have deployed my all code and it is difficult to change this thing on whole application.Perhaps there is any way using globalization element in web.config.
N!dh!
|
|
|
|
|
I guess you can change it on database table's column definition. There is no code change require for this.
dnpro
"Very bad programmer"
|
|
|
|
|
Is there any way to convert timezone from database side by changing only definition,not by makeing any changes on procedure
N!dh!
|
|
|
|
|
Hi,
I am working on a dynamic generation of form. i have one dropdown menu and one change of drop down menu it generates set of radio button options.. one the button click i want to retrive the id's of radiobutton. but everytime it gives me return value....
when i generate radio button on form dynamically on page load then it is not a problem findcontrol works properly. i think problem is with change of dropdownlist because i am generating my radio buttons on selection change.... i am missing smthg. any kind of help will be highly appreciated ....
|
|
|
|
|
could you show your code? Thah might tell more.
|
|
|
|
|
protected void btnsubmit_OnClick(object sender, EventArgs e)
{
string sqlStr1 = "SELECT * FROM valuess";
dAdapter2 = new OleDbDataAdapter(sqlStr1, connectionString);
dset2 = new DataSet();
dAdapter2.Fill(dset2, "value_name");
dAdapter2.Dispose();
dt2 = new DataTable();
dt2 = dset2.Tables["value_name"];
string radio1;
radio1 = "radioButton_" + dt2.Rows[0]["value_name"].ToString();
RadioButton rb_1 = new RadioButton();
rb_1 = (RadioButton)Page.FindControl(radio1.ToString());
}
I am creating these radio buttons in selection change event of dropdownlist......
|
|
|
|
|
You recreate the radiobuttons in the onclick event of the button.
after that event has ended your radiobuttons do not exist anymore.
You should state in the beginning of the class (not the event)
RadioButton rb_1;
Then all methods and events refer to the same radiobuttons.
|
|
|
|