|
Hi all,
i have developed one asp.net application and set the session timeout for 20 minutes but how i don't know
my session is timed out not correctly
means, it would be timeout in 1 minute, sometimes it take 20 minute, some time it take 10 minute
why it is ?????
please help...
any setting in Web.Config or Global.asax ??
thankx in advance
regards,
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
The setting is in web.config, amd set in minutes:
<sessionState
timeout="20"
/>
- but if you're running this locally on XP don't worry about it; IIS on XP has a mind of it's own, and times out whenever it gets bored and feels like it.
It should work correctly on a proper web server.
Fred
|
|
|
|
|
how to append the listitems as a comma seperated string and insert into the database in a single row using asp.net 2.0 I am using vb. I am copying a content of listbox1 to listbox2. I want to store the listbox2 data into database. I am using the following code, But the each value is getting stored in different row of the table. I want them to get stored in a single row.
Dim str As String
If dbconn.State ConnectionState.Open Then
dbconn.Open()
End If
For Each item As ListItem In lstselectedemployees.Items
str = "insert into a (soft)values('" & item.Text & "')"
Dim comm As New SqlCommand(str, dbconn)
Try
comm.ExecuteNonQuery()
Label1.ForeColor = Drawing.Color.Green
Label1.Text = "Success"
Catch ex As Exception
Label1.Text = ex.Message
End Try
Next
If I use the following code then, only the last item of the list box is getting stored,
Dim str As String
If dbconn.State ConnectionState.Open Then
dbconn.Open()
End If
For Each item As ListItem In lstselectedemployees.Items
str = "insert into a (soft)values('" & item.Text & "')"
Next
Dim comm As New SqlCommand(str, dbconn)
Try
comm.ExecuteNonQuery()
Label1.ForeColor = Drawing.Color.Green
Label1.Text = "Success"
Catch ex As Exception
Label1.Text = ex.Message
End Try
Chaitra N
|
|
|
|
|
Dim str As String
If dbconn.State ConnectionState.Open Then
dbconn.Open()
End If
For Each item As ListItem In lstselectedemployees.Items
STR = STR & "," & item.Text
Next
str2="insert into a (soft)values('" & STR & "')"
Dim comm As New SqlCommand(str2, dbconn)
Try
comm.ExecuteNonQuery()
Label1.ForeColor = Drawing.Color.Green
Label1.Text = "Success"
Catch ex As Exception
Label1.Text = ex.Message
End Try
|
|
|
|
|
Thank you JC. This is working, But it store a ',' in the very beginning. How to stop this.
Example, if the items are,
A
B
C
It stores ,A,B,C
Chaitra N
|
|
|
|
|
Oh come on. He's done the hard bit for you. Try doing at least some of it yourself.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Dim str As String = ""<br />
If dbconn.State ConnectionState.Open Then<br />
dbconn.Open()<br />
End If<br />
For Each item As ListItem In lstselectedemployees.Items <br />
if str = "" then<br />
str = item.Text<br />
else<br />
STR = STR & "," & item.Text<br />
end if<br />
Next<br />
str2="insert into a (soft)values('" & STR & "')"<br />
Dim comm As New SqlCommand(str2, dbconn)<br />
Try<br />
comm.ExecuteNonQuery()<br />
Label1.ForeColor = Drawing.Color.Green<br />
Label1.Text = "Success"<br />
Catch ex As Exception<br />
Label1.Text = ex.Message<br />
End Try
Try Bold text
B asharatA li
Internee
METESYS Lahore
Pakistan
|
|
|
|
|
Thank u. It is working.
Chaitra N
|
|
|
|
|
Well, if you want me to do all the work, it might help if you rated my reply
hint: use the mid-function
|
|
|
|
|
Thank u JC. I gotta know the code. Your code really helped me.
Chaitra N
|
|
|
|
|
I have one more doubt. This is regarding bindng of listbox.
Let us assume I store A B C D in from listbox2. It stores as A,B,C,D . When i bind the data to listbox it comes as the same. But i want to display each value in different row. How to do this? I tried split function but no use. Here is the code snippet i have used to bind the data to listbox, lstselectedemployees is the listbox.
Dim sql As String = "Select * from A_desktops where assetcode='" & TextBox1.Text & "'"
Dim da As New SqlDataAdapter(sql, dbconn)
Dim ds As New DataSet()
da.Fill(ds, "a_desktops")
lstselectedemployees.DataSource = ds.Tables("a_desktops").DefaultView
lstselectedemployees.SelectedIndex = 0
lstselectedemployees.DataTextField = "swinstalled"
Page.DataBind()
Chaitra N
|
|
|
|
|
First u should convert list items into one string seperated by comm(,) and stored it in a string type variable with concatenation.
and then stored the variable into datbase field.
Use this code for converting
global decalartion
dim i as int
dim st as string
for i=0 to i<=ListBox1.item.count-1
if i<>ListBox1.item.count-1 then
st +=ListBox1.item(i) & ","
else
st +=ListBox1.item(i)
End if
Next
BY Nand
Nand
|
|
|
|
|
I have one more doubt. This is regarding bindng of listbox.
Let us assume I store A B C D in from listbox2. It stores as A,B,C,D . When i bind the data to listbox it comes as the same. But i want to display each value in different row. How to do this? I tried split function but no use. Here is the code snippet i have used to bind the data to listbox, lstselectedemployees is the listbox.
Dim sql As String = "Select * from A_desktops where assetcode='" & TextBox1.Text & "'"
Dim da As New SqlDataAdapter(sql, dbconn)
Dim ds As New DataSet()
da.Fill(ds, "a_desktops")
lstselectedemployees.DataSource = ds.Tables("a_desktops").DefaultView
lstselectedemployees.SelectedIndex = 0
lstselectedemployees.DataTextField = "swinstalled"
Page.DataBind()
Chaitra N
|
|
|
|
|
Learn how to properly post code snippets here at CP.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I would like to learn that, any links to where it is explained?
|
|
|
|
|
Hi,
Not quite sure where to post this, but as it's for an asp page, this seems like the right place.
I'm trying to convert a codeproject project from C# to VB and am coming unstuck with raising events. can anyone tell me where i'm going wrong?
C# code:
public delegate void CaptchaEventHandler();
public partial class CaptchaControl : System.Web.UI.UserControl
public event CaptchaEventHandler Success
{
add { success += value; }
remove { success += null; }
end class
poorly vb code is:
Public Delegate Sub CaptchaEventHandler()
Partial Public Class CaptchaControl
Public Custom Event Success As CaptchaEventHandler
AddHandler(ByVal value As CaptchaEventHandler)
success += value
End AddHandler
RemoveHandler(ByVal value As CaptchaEventHandler)
success += Nothing
End RemoveHandler
End Event
But i just get "missing raiseevent" errors
Many Thanks
|
|
|
|
|
I think it's like this not sure
<br />
Public delegate Sub CaptchaEventHandler()<br />
Public partial Class CaptchaControl<br />
Inherits System.Web.UI.UserControlPublic event CaptchaEventHandler Success<br />
Public delegate Sub CaptchaEventHandler()<br />
Public partial class CaptchaControl : System.Web.UI.UserControlPublic event CaptchaEventHandler Success <br />
<br />
End Class<br />
{<br />
add <br />
{<br />
success += value <br />
}<br />
remove <br />
{<br />
success += Nothing <br />
}<br />
end class
B asharatA li
Internee
METESYS Lahore
Pakistan
|
|
|
|
|
Thanks for your reply,
This is not quite right, the c# code works fine, but i want to use VB.
|
|
|
|
|
As I've indicated on other forums for this same sample, the VB equivalent is:
Public Delegate Sub CaptchaEventHandler()
Public Partial Class CaptchaControl
Inherits System.Web.UI.UserControl
Public Custom Event Success As CaptchaEventHandler
AddHandler(ByVal value As CaptchaEventHandler)
AddHandler success, value
End AddHandler
RemoveHandler(ByVal value As CaptchaEventHandler)
RemoveHandler success, value
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As EventArgs)
End RaiseEvent
End Event
End Class
Note that the original C# code is very badly formed - the "success += null" is almost certainly a mistake and should have been "success -= value".
David Anton
http://www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
C++ to VB Converter: converts C++ to VB
Instant C++: converts C# to C++/CLI and VB to C++/CLI
|
|
|
|
|
Hi all, I have a page which works fine on my local computer, but when I upload it to my server it gives the following error. Can any one tell me the reason of that error and possible solution for that.
System.Data.OleDb.OleDbException: Cannot open any more tables. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.ExecuteReader() at cust_order.custOrdDes() in c:\domains\etradehouse.com\wwwroot\code\adm\cust_det\adm_order_det.aspx.vb:line 2090
and the code of that sub is given belown
Public Sub custOrd()
customerAsc.Clear()
customer.Clear()
Try
If Conn.State <> 0 Then
Conn.Close()
End If
Conn.Open()
SelectQuery = "select order_id from cust_order"
command = New OleDbCommand(SelectQuery, Conn)
total = command.ExecuteReader()
While total.Read
ordAsc.Add(total.GetValue(0))
End While
Dim i As Integer
For i = 0 To ordAsc.Count - 1
SelectQuery = "SELECT customers.customer_id,customers.customer_type FROM customers INNER JOIN cust_order ON customers.customer_id=cust_order.customer_id WHERE cust_order.order_id=" & ordAsc(i) & ""
command = New OleDbCommand(SelectQuery, Conn)
total = command.ExecuteReader()
While total.Read()
cstAsc.Add(total.GetValue(0))
typAsc.Add(total.GetValue(1))
End While
Next
total.Close()
total = Nothing
Dim k As Integer
For k = 0 To cstAsc.Count - 1
If typAsc(k) = 1 Then
SelectQuery = "Select comp_name, customer_id from biz_cust_extra where customer_id = " & cstAsc(k)
command = New OleDbCommand(SelectQuery, Conn)
total = command.ExecuteReader()
While total.Read()
If Not total.IsDBNull(0) Then
customerAsc.Add(total.GetValue(0) & "," & total.GetValue(1))
End If
End While
Else
SelectQuery = "Select fname, lname, customer_id from customers where customer_id = " & cstAsc(k)
command = New OleDbCommand(SelectQuery, Conn)
total = command.ExecuteReader()
While total.Read()
If Not total.IsDBNull(0) Then
customerAsc.Add(total.GetValue(0) & " " & total.GetValue(1) & "," & total.GetValue(2))
End If
End While
End If
Next
total.Close()
total = Nothing
Dim customer As New ArrayList
Dim cust As Array
customerAsc.Sort()
Dim j As Integer
For j = 0 To customerAsc.Count - 1
cust = Split(customerAsc(j).ToString, ",")
customer.Add(cust(1))
Next
Dim l As Integer
Dim str As String = ""
For l = 0 To customer.Count - 1
If l = 0 Then
str &= "txtSearch=" & customer(l)
Else
str &= "&txtSearch=" & customer(l)
End If
Next
Response.Redirect("/code/adm/cust_det/adm_order_det.aspx?index=32&" & str)
Catch ex As Exception
Response.Write(ex.ToString)
Finally
Conn.Close()
End Try
End Sub
the line 2090 is underline in above code.
Pls help me its very urgent.
Thanks in Advance.
|
|
|
|
|
I see you havnt closed your reader 'total' after the first query.
try, total.Close()
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Now I close it but it still gives the same error. Can u tell me what is the reason and possible solution for that.
|
|
|
|
|
OK, see this
<br />
For i = 0 To ordAsc.Count - 1<br />
SelectQuery = "SELECT customers.customer_id,customers.customer_type FROM customers INNER JOIN cust_order ON customers.customer_id=cust_order.customer_id WHERE cust_order.order_id=" & ordAsc(i) & ""<br />
command = New OleDbCommand(SelectQuery, Conn)<br />
total = command.ExecuteReader()<br />
While total.Read()<br />
cstAsc.Add(total.GetValue(0))<br />
typAsc.Add(total.GetValue(1))<br />
End While<br />
Next<br />
Here you are looping thru some list and executing reader without closing it. That is why it is throwing exception. Make sure you close the reader after you finish fetching records.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Can u pls tell me where should i close reader in my code. I m new to programming so why i m facig problems.
|
|
|
|
|
Sure..
<br />
For i = 0 To ordAsc.Count - 1<br />
SelectQuery = "SELECT customers.customer_id,customers.customer_type FROM customers INNER JOIN cust_order ON customers.customer_id=cust_order.customer_id WHERE cust_order.order_id=" & ordAsc(i) & ""<br />
command = New OleDbCommand(SelectQuery, Conn)<br />
total = command.ExecuteReader()<br />
While total.Read()<br />
cstAsc.Add(total.GetValue(0))<br />
typAsc.Add(total.GetValue(1))<br />
End While<br />
total.Close() '<---<br />
Next<br />
See above, right after the while loop. I see you have the same mistake in all your code. Fix them with the same
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|