|
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.
|
|
|
|
|
I have done according to ur answer but now another problem occured
and following error occured.
The page cannot be displayed
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings
|
|
|
|
|
Good, so you are out of one problem.
Now it seems like your program stuck into a never ending loop. It is a typical logical error, try debugging your code.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Thank u very much dear.
Now I will find out what is the error.
I think u r Pakistani. I m also Pakistani. My name is Arif Bangash. And I m new to programming. Will u help me in making myself a good programmer. Can u pls give me ur email address with help of which I can contact u.
|
|
|
|
|
Yea I am a proud Paki
you can find me on mubashir01@hotmail.com
regards,
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
In .net we have try catch and final blocks are there...or anymore...like
throw and throws ..i think they are in java...is it in .net too...can anybody tell and explain abt them.?
pavan...
|
|
|
|
|
In a Try Catch block you can re- throw an exception so that it gets caught again later in the code. You can also use throw inside the try so that you go to the catch logic. The syntax is:
throw new Exception...
Hope that helps.
Ben
|
|
|
|
|
|
hi ...
cud any1 help me in calling server method on browser close event or alt+f4.. plz...
|
|
|
|
|
itzmevishu wrote: cud any1
Please speak English. txt is great for your 14 year old mates, not here.
No, it cannot be done. nothing is sent to the server when the browser is closed.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|