|
Can ListItem be used in vb.net 2005?
When I use the code:
For Each item As ListItem in listbox2.Items<br />
If item.Value = fi.Name Then<br />
fFound = True<br />
End If
I will tell me to change ListItem to ListViewItem. When I change it I get the error:
Unable to cast object of type 'System.String' to type 'System.Windows.Forms.ListViewItem'.
Any suggestions?
jds1207
|
|
|
|
|
ListItem is a class in System.Web.UI.WebControls , it looks like your trying to use that in a windows form application.
jds1207 wrote: will tell me to change ListItem to ListViewItem. When I change it I get the error:
Unable to cast object of type 'System.String' to type 'System.Windows.Forms.ListViewItem
That will not work, you cant use a ListViewItem for a listBox
The ListBox.Items is an Object collection
For Each item As Object In listBox2.Items
If Convert.ToString(item) = fi.Name Then
fFound = True
End If
Next
|
|
|
|
|
i am trying to make an oledb connection with a password protected Access databaase.I tried the vizard on vb.net.but i got a connection error as " Cant start ur application because either Work group information file is missing or it is opened exclusievly by one another.please help me
|
|
|
|
|
Hi,
an example to connect to an Access database:
Dim sql As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _<br />
"Data Source=c:\resource.mdb;Jet OLEDB:System database=\\system.mdw;User Id=; Password=;"<br />
<br />
Using connection As New OleDb.OleDbConnection(sql)<br />
<br />
connection.ConnectionString = sql<br />
connection.Open()
System database is the path where you have Work group information and Data Source is the path where is your database.
Hope this help.
regards.
-- modified at 2:26 Wednesday 13th June, 2007
|
|
|
|
|
in my computer i use 2 ip address
i create a comuniction application using UDP and connect to server ( send and recive working good)
and now i whand to send data from the second ip address
how i can config to UdpClient to use the first ip or the second ?
Thanks
|
|
|
|
|
to send -
you can either randomize
you can use sequential - 1 then 2 then 1 then 2 etc
you can look at the PC's ip and if the last number is odd, use 1 else use 2
to receive -
you need to setup 2 listeners to handle both IPs
|
|
|
|
|
how i can select the localIp address
i use the UDPClient and i dont see where to insert my local ip
i need to send data from the first IPAddress and then send data from the second ipaddress
both send to the same ipaddress
|
|
|
|
|
Hi,
I'm using VB.NET 1.1.
I have a SqlDataReader varible that calls a function that has a return type of SqlDataReader like:
Dim dr As SqlDataReader = Me.GetProductsDataReader()
The function GetProductsDataReader() doesn't close the SqlDataReader any where, but then when I try to do (after the call):
While dr.Read()
' code here
End While
..then I get the following erro:
Invalid attempt to Read when reader is closed.
Please can some one help me?
Regards
ma se
|
|
|
|
|
Could you show your code in GetProductsDataReader() ?
|
|
|
|
|
Hi,
better you use
dim cmd1 As SqlCommand = conn.CreateCommand()<br />
Dim drd1 As SqlDataReader = cmd1.ExecuteReader()<br />
while drd1.read()<br />
..<br />
end while<br />
hope this would help.
regards
|
|
|
|
|
hi,
Did you closed the datareader before in your prog ???
please post your code of GetProductsDataReader()
regards,
koolprasad2003
If the message is useful for U then please Rate This message...
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
I'm using VS 2005 with SP1. I created a user control. In the same solution I created a new project to test the control. In the test project, I added a reference to the user control project. My user control does not show up in the toolbox. What do I have to do to have it show up?
Thanks,
VF
|
|
|
|
|
add it manually - right-click on toolbox and click add and choose your dll...
|
|
|
|
|
There isn't an "Add" when I right-click on the toolbox.
However, I used the "Add tab", and entered an appropriate name. Then I dragged my dll file into the area in the new tab. Now it shows up.
|
|
|
|
|
sorry went by memory -- see what that got me...
it's actually "choose item" will allow you to add to the toolbox.
|
|
|
|
|
"Choose Items..." and browsing to the dll also works.
Next question: How do I modify the icon for the user control that is displayed in the toolbox. I looked for an Icon property for my user control, but there doesn't seem to be one.
|
|
|
|
|
You don't have to add it manually. This SHOULD show up automatically when you build the project. But, it's been known to screw up. Sometimes closing Visual Studio and restarting it, loading your project and recompiling takes care of it. Other times, you have to right-click the Toolbox and pick Reset Toolbox.
|
|
|
|
|
Still doesn't work. At least I can add it manually.
Do you know how I can modify the icon that shows up in the toolbox? Doesn't seem to be an Icon property for the user control.
|
|
|
|
|
You can't. The icon in the ToolBox doesn't show up properly at all during development. It won't show a proper icon until the control is finalized in a Release build and is registered in the GAC, complete with strong name.
|
|
|
|
|
Hi,
I'm using VB2005 Express to create a small app which is intended to allow me to build up the contents of an XML file.
I've got the DataGridView in place, and it is reading in and displaying the contents of an XML file.
I've got a button on the form which allows me to insert a column in the DataGridView, but when I press 'Save' it writes an XML file, but it doesn't include the new column I've just entered in my grid.
I suspect that it may be a binding problem, but I don't know how to code this part of the app.
Any advice would be appreciated.
|
|
|
|
|
You can try this :
'=====Read and display xml file on DataGridView=====
Dim ds as new DataSet
ds.ReadXml("c:\YourFile.xml")
dgv.DataSource = ds.Tables(0)
'=====End=====
'=====Create new column=====
Dim col as new DataColumn("MyNewColumn",System.Type.GetType("System.String"))
ds.Tables(0).Columns.Add(col)
'=====End=====
'=====Save xml file
ds.WriteXml("c:\\YourFile.xml")
'=====End=====
|
|
|
|
|
OK. This is a typical newbie misconception. The DataGridVIEW doesn't hold the data you're looking at. It mearly SHOWS it. The data is being held is a DataSet object, which is a collection of DataTables and DataRelation object. DataTables hold DataColumns and DataRows.
If you added the column to the DataGridView, you just added a column that can be used to VIEW data, not hold it. You have to add the new column to the DataTable that will hold the data your adding. This will update the schema that's used to write the XML file.
|
|
|
|
|
Thanks for your reply.
I am new-ish to it, and was aware that I was adding the column to my 'view'. I had already tried adding the column to my table, but it just didn't seem to work, which is why I assumed there was some sort of binding problem going on.
If it isn't a binding problem, I must be doing something wrong.
Am I right in thinking that if I read the XML file in, I've automatically got my dataset and tables to work with, and if I update my table in any way I choose (i.e. adding/deleting rows/columns), it is the same table in the exact same dataset that I write back to XML?
|
|
|
|
|
penguin5000 wrote: I had already tried adding the column to my table, but it just didn't seem to work, which is why I assumed there was some sort of binding problem going on.
If you want to see this change, then you either have to manually add the new column to the DGV, or just rebind the DGV to your datasource so it can regenerate the columns it needs to display the data.
penguin5000 wrote: Am I right in thinking that if I read the XML file in, I've automatically got my dataset and tables to work with, and if I update my table in any way I choose (i.e. adding/deleting rows/columns), it is the same table in the exact same dataset that I write back to XML?
Yes. This will overwrite the existing XML file with the new data and schema.
|
|
|
|
|
Guys,
I'm using a CreateObject("objectname"); to attach to an executable (run with windows logon account). Mostly this works fine, but sometimes we need to attach from a service (run under the system account) In this case the CreateObject function doesn't seem to see the executable (windows logon account) running and creates a new instance.
Any idea how to resolve this?
thanks a lot !
|
|
|
|