|
It was my quick answer
Addition in my previous post: After the job is done with file then file can be deleted
FileInfo fdelete = new FileInfo(Server.MapPath("~/UplDoc/filename.extension"));<br />
fdelete.Delete();
I Love SQL
|
|
|
|
|
Hi All!
in my application, there is a table tblCountries(countryId,countryName) & i have a class: person
public class Person
{
private string name;
private int countryID;
public string Name
{
get {return this.name;}
set {this.name = value;}
}
public string CountryId
{
get {return this.countryID;}
set {this.countryID= value;}
}
}
now i want to add an property CountryName which returns name of the country name rather than country . can any one help me in this regards?
|
|
|
|
|
Smells like homework, but...
Check out DataTable.Select.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I have a transaction that adds sql statements between postbacks that occur at specific button clicks. And the transaction is finally commited at another button click.
Each time the postback occurs the sql commands are added to the transaction without any problem but finally when i commit it, an exception occurs that says:
"This SqlTransaction is completed; it is no longer usable."
When I viewed the property of the transaction object while debugging I ve noticed a Timeout property that has the value 15. I dont know whether it is in seconds or minutes. I think it is due to the timeout the transaction is gettting completed.
I have declared the transaction globally in my page say "MemberLinking.aspx" as:
<br />
Private Shared myTrans As SqlTransaction<br />
I have then passed the transaction to a function defined in a class file like this:
<br />
Public Sub BeginTransaction(ByRef tsql As SqlTransaction)<br />
Try<br />
tsql = conn.BeginTransaction()<br />
Catch ex As Exception<br />
Finally<br />
End Try<br />
End Sub<br />
This function begins the transaction. The other functions that adds the commands to the transaction are also passed the transaction as parameter. Vut it is done by value.
I have added the sql statements to the transaction as:
<br />
sqlstatement = "UPDATE UserFamily SET UserID=" & LinkedUID & " WHERE UserID=" & UID & " AND FamilyID=" & FID<br />
cmd = ReturnSqlCommand(sqlstatement)<br />
cmd.Transaction = Mytrans<br />
cmd.ExecuteNonQuery()<br />
<br />
sqlstatement = "INSERT INTO UserFamily(UserID,FamilyID,Accepted,IsModerator) VALUES (" & ChildID & "," & FamilyID & _<br />
",1,0)"<br />
cmd = ReturnSqlCommand(sqlstatement)<br />
cmd.Transaction = Mytrans<br />
cmd.ExecuteNonQuery()<br />
where ReturnSqlCommand() is a function that takes as string a parameter and returns it as an SqlCommand object. The above two are not the only statements. The application adds a set of statements at each postbacks. Through out this process there is no error or exception utill i try to commit or rollback the transaction object.
|
|
|
|
|
AFAIK: Everytime you postback, your page and all it's code behind variables are recreated and reinitialized, but controls retain their values because of the magical viewstate.
SqlTransaction doesn't have any concept of viewstate, so it's a fresh new SqlTransaction each time.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Thank you Steve
Is it anyway possible to preserve the transaction b/w postbacks? Is there any chance of transaction getting timed out?
|
|
|
|
|
Hello,
In my internet site, i have to proivde search functionality within the website domain. Could you please give some light where should i look for related articles,sample code, ideas etc....
Thanks,
Thanks
|
|
|
|
|
|
I have a string
bobby@yahoo.com (Bobby Gill)
I want to parse it and want to get the substring "bobby@yahoo.com" before space.
Could you please give me code.
thanks
seema
|
|
|
|
|
I didn't quite understand what you want. Can you explain a bit more
|
|
|
|
|
string s="bobby@yahoo.com (Bobby Gill)"<br />
int indx=s.IndexOf(' ');<br />
string val=s.Substring(0,indx);
OR
string s="bobby@yahoo.com (Bobby Gill)"<br />
string[] ss=s.Split(' ');<br />
int count=0;<br />
string val;<br />
foreach(string s1 in ss)<br />
{<br />
if(count==0)<br />
{<br />
val=s1;<br />
}<br />
count=1;<br />
}
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
Hi all,
I'm trying to make an asp.net data entry table work like they do in access. what i want is a one line table with 3 columns (a time picker, a drop down, and a comments section). When the line is fully populated, I'd like a new empty line to appear below so the user can continue to add any number of lines.
I can't figure out any easy way to do this, and that usually means i'm missing something simple any help is greatly appreciated!
thanks in advance,
Craig
|
|
|
|
|
try repeater control or datagrid and add template columns
Shujaat
|
|
|
|
|
have a AutoCompleteExtender and I bound it to a textbox. It is the list of
all email address and last name and first name
nMultani@dov.gc.ca (nancy Multani)
bGill@dov.gc.ca (babay Gill)
I want to validate this text box. I want to create new validation control
the text box I type only that item which appear in drop down list or select
valid item or type whole string.
How can I do that.
seema
|
|
|
|
|
I have a gridview that, depending on the information being passed to it, needs to flag the Visible attribute of a textbox control in one of the template columns. so here is a quick snippet of the datarow as it is being built:
dr[4] = "";
dr[5] = s;
dr[6] = "false";
the datatable columns it references:
dt.Columns.Add("filler");
dt.Columns.Add("key");
dt.Columns.Add("Vis");
and the line in the gridview that is having issues:
<asp:TextBox ID="txtItmQty" runat="server" Text='<%# Bind("filler") %>' Width="42px" Visible='<%# Bind("Vis") %>'></asp:TextBox>
every time i run it, i get this:
<b>Specified cast is not valid.</b>
how or what do i have to pass to the Visible attribute to set this dynamically?
-- modified at 18:14 Thursday 13th September, 2007
______________________
Mr Griffin, eleventy billion is not a number...
-- modified at 18:14 Thursday 13th September, 2007
|
|
|
|
|
try <%# Eval("filler") %> Instead of <%# Bind("filler") %>
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
i m assuming that u store bool value in your "Vis" Field.According to that below solution is given...
public string GetValue(bool Vis)
{
if (Vis)
return "true";
else
return "false";
}
Visible='<%# GetValue(Convert.ToBoolean(DataBinder.Eval(Container.DataItem,"Vis"))) %>'
i thinks this will work
-- modified at 1:56 Friday 14th September, 2007
Jintal Patel
|
|
|
|
|
When i store a cookie, id doesn't remeber even if i use refresh
Using VS2005 SP1
Thank's in advance
|
|
|
|
|
How do you store the cookie, and how do you try to read it?
---
single minded; short sighted; long gone;
|
|
|
|
|
To Write
Response.Cookies["UserName"].Value = txtUserName.Text;
Response.Cookies["UserName"].Expires = core.cookieExpire();
Response.Cookies["Password"].Value = txtPassword.Text;
Response.Cookies["Password"].Expires = core.cookieExpire();
public DateTime cookieExpire()
{
DateTime dt = DateTime.Now;
dt.AddYears(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireYear"]));
dt.AddMonths(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireMonth"]));
dt.AddDays(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireDay"]));
dt.AddHours(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireHour"]));
dt.AddMinutes(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireMinutes"]));
return dt;
}
<configuration>
<appSettings>
<add key="CookieExpireYear" value="1"/>
<add key="CookieExpireMonth" value="0"/>
<add key="CookieExpireDay" value="0"/>
<add key="CookieExpireHour" value="0"/>
<add key="CookieExpireMinutes" value="0"/>
</appSettings>
<connectionStrings>
To Read
HttpCookie cookieUserName = Request.Cookies["UserName"];
HttpCookie cookiePassword = Request.Cookies["Password"];
|
|
|
|
|
Saksida Bojan wrote: public DateTime cookieExpire()
{
DateTime dt = DateTime.Now;
dt.AddYears(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireYear"]));
dt.AddMonths(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireMonth"]));
dt.AddDays(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireDay"]));
dt.AddHours(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireHour"]));
dt.AddMinutes(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireMinutes"]));
return dt;
}
The methods in the DateTime structure doesn't change the value, they return the new value. That means that the cookieExpire method returns DateTime.Now , which will make your cookies expire immediately.
This will give you a better result:
public DateTime cookieExpire() {
return DateTime.Now
.AddYears(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireYear"]))
.AddMonths(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireMonth"]))
.AddDays(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireDay"]))
.AddHours(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireHour"]))
.AddMinutes(Convert.ToInt32(ConfigurationManager.AppSettings["CookieExpireMinutes"]));
}
---
single minded; short sighted; long gone;
|
|
|
|
|
|
I have a textBox Where I type date. I want to validate it. Im using customValidate controls. I have this function in my code behind page
void DatesValidate(object source, ServerValidateEventArgs e)
{
if (Convert.ToDateTime(e.Value) <= DateTime.Now)
{
e.IsValid = false;
this.lblAddUsers.Text = "The Proxy is already expired";
}
}
<asp:customvalidator id="cvEndDate" runat="server" onservervalidate="DatesValidate"
="" controltovalidate="txtTo" errormessage="error" display="Dynamic">
It is not working it is giving the follo2ing error
'Proxy.DatesValidate(object, System.Web.UI.WebControls.ServerValidateEventArgs)' is inaccessible due to its protection level
seema
|
|
|
|
|
I have a textBox Where I type date. I want to validate it. Im using customValidate controls. I have this function in my code behind page
void DatesValidate(object source, ServerValidateEventArgs e)
{
if (Convert.ToDateTime(e.Value) <= DateTime.Now)
{
e.IsValid = false;
this.lblAddUsers.Text = "The Proxy is already expired";
}
}
<asp:customvalidator id="cvEndDate" runat="server" onservervalidate="DatesValidate"
="" controltovalidate="txtTo" errormessage="error" display="Dynamic">
It is not working it is giving the follo2ing error
'Proxy.DatesValidate(object, System.Web.UI.WebControls.ServerValidateEventArgs)' is inaccessible due to its protection level
seema
|
|
|
|
|
Use the protected access modifier in front of the method declaration. By default, methods are private when specified without an access modifier.
Jon Sagara
Once again, the conservative sandwich-heavy portfolio pays off for the hungry investor! *slurp* Oh, I'm ruined!
-- Dr. Zoidberg
.NET Blog | Personal Blog | Articles
|
|
|
|