|
access thing should work fine for you buddy,
|
|
|
|
|
Yeah, I'm now trying to figure out how to read data from the Access file.
As I sit here, I contemplate the last words of Socrates: "I drank what?".
Pokémon Pearl Friend Code: 4554-2418-6836
|
|
|
|
|
Dim connect As New OleDbConnection
connect.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdatabase.mdb;Persist Security Info=True"
connect.Open()
your code and sql here..
connect.Close()
|
|
|
|
|
Yeah, tried that... see this thread[^]
I dunno. I'll keep trying different things, but if anyone has ever done anything like this again and has some code (or can at least figure out what's wrong with my code), I would appreciate it a bunch.
Thanks!
As I sit here, I contemplate the last words of Socrates: "I drank what?".
Pokémon Pearl Friend Code: 4554-2418-6836
|
|
|
|
|
Hi,
I am trying to call a form from my custom control (ComboBox), I have a property in the custom control to get the form name.
After adding the component to the form I can only select the current form (the component's parent form).
What should I do to get all the form names there (or at least type a form name).
Public Shadows Property NewForm() As System.Windows.Forms.Form
Get
Return _frm
End Get
Set(ByVal Value As System.Windows.Forms.Form)
_frm = Value
End Set
End Property
Thanks in advance.
|
|
|
|
|
Randana wrote: What should I do to get all the form names there (or at least type a form name).
Which form name do you wanna get here...
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi,
what i need is to give a form name of a form in the project as the property at design time. So that at run time i can call that form.
thanks for replying.
|
|
|
|
|
It is a bit confusing that your post mentions just the form's name, but code you provided returns a form.
Keep in mind that a form is nothing more than a class with a visual interface. This means that anything you can do with a class, you can do with a form. Since ComboBoxes can hold any item, there is no reason they could not hold references to the forms you are using:
Dim F1 As New MyFormOne
Dim F2 As New MyFormTwo
Dim MyCntl As New MyControl
MyCntl.Items.Add(F1)
MyCntl.Items.Add(F2) The text that is displayed in the ComboBox is derived from the object's ToString method. To have the box display the name, override this method in the form definition, like this:
Public Overrides Function ToString() As String
Return Me.Name
End Function Lastly, you can retrieve the form itself by looking at the ComboBox' SelectedItem property:
Dim SelectedForm As Form = Nothing
If MyCntl.SelectedItem IsNot Nothing Then
SelectedForm = CType(MyCntl.SelectedItem, Form)
End If From here, you can do whatever you want with SelectedForm. Hope this helps.
|
|
|
|
|
When I Open a modal form in vb.net 3.5 application, I want to make the background form semi transparant.
Just like windows.
How it is Possible?
Please, Help me.
|
|
|
|
|
Set the Opacity property of the form to some value less than 100(depends how much transparent you want )
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
It not just the transparant.
I wanted that when I open a Modal form then the back ground form color will be Faded.
just like when you click on the Shutdown button of the windows the background will be faded out
|
|
|
|
|
Hi folks, I hope someone can help me with a VB.NET problem, as it has been driving me bananas all day.
I have a checkbox which is binded to a datatable. Some example code is shown below:
' Access the database<br />
strSQL = "SELECT ID, Name FROM tblMYTABLE"<br />
cnnData.ConnectionString = "[information about my Microsoft Access database]"<br />
cnnData.open()<br />
daData = new OleDb.OleDbDataAdapter(strSQL, cnnData)<br />
cbData = new OleDb.OleDbCommandBuilder(daData)<br />
daData.Fill(dtData)<br />
<br />
' Bind the table to the checkbox (assuming there are records in tblMYTABLE)<br />
<br />
cboMyTable.DataSource = dtData<br />
cboMyTable.DataBindings.Add("Tag", dtData, "ID")<br />
cboMyTable.DataBindings.Add("Text", dtData, "Name")<br />
cboMyTable.DisplayMember = "Name"
So far, everything is working fine - all records in the tblMYTABLE table are shown as individual checkbox items.
However, here is the problem I have been having. I have another table in the database (a many-to-many table with two fields, both of which are the primary keys of other tables) which essentially will dictate whether or not one of the checkbox items generated above is checked or not. To give an example, let's say tblMYTABLE contains the following records:
ID Name
-=-----
1 Jim
2 Joe
3 John
4 Jill
5 Jack
The many-to-many table contains the following IDs from tblMYTABLE (let us call this table tblMANYTOMANY, and let us assume for simplicity that OtherID doesn't matter in this case):
ID OtherID
------------
1 65
4 65
2 65
Therefore, in the checkbox above, I would want to show the items relating to Jim, Jill and Joe as being ticked. I would like this to be done either during the binding process itself (i.e. within the code shown above) or as a separate piece of code immediately afterwards which goes through each of the items and checks them off as necessary, but for the life of me I've no idea how this would be done.
What I would like to do is something like this:
Dim i as integer<br />
<br />
For i = 0 to (cboMyTable.Items.Count - 1)<br />
<br />
strSQL_SecondSQL = "SELECT ID, OtherID FROM tblMANYTOMANY WHERE OtherID=65 AND ID=" & cboMyTable.Items.Tag<br />
<br />
' Open the table, if there is a record there then check the item, if not, leave it as unchecked <br />
<br />
Next
The problem above is that there is no "movement" through the items (or none that I can see), i.e. there is no movement from the first item to the second, the second to the third and so on. I suppose the other way of doing it would be something like (using ASP-style script):
while not (cboMyTable.Items.Count - 1)<br />
<br />
' My code<br />
<br />
cboMyTable.Item.MoveNext<br />
<br />
wend
However, there is no MoveNext property.
I know I could probably use arrays, or to change the original SQL statement, but I don't want to over-complicate the code if it is just a simple thing to fix...
Sorry this sounds very confusing - I hope someone can help!
c0ley
|
|
|
|
|
First one clarifying question.
Is cboMyTable really a checkbox or for example a checked listbox? If it would be a single check box your code wouldn't compile since CheckBox class doesn't have Items property.
Mika
|
|
|
|
|
Hi, yeah it's a checked listbox.
|
|
|
|
|
Okay, first point (based on documentation, which is a bit confusing after your observations)
CheckedListBox.DataSource Property
Gets or sets the data source for the control. This property is not relevant for this class
Back to your question, instead of MoveNext (which doesn't exist) you could use the indexer of Items property (well actually indexer of the ListBox.ObjectCollection class)
In VB I recall that the syntax is
cboMyTable.Item(counter)
However you could also modify the SQL statement so that you don't loop each item in the listbox, but instead you first get all the records and then match them to items. In this case you would use SQL statement like
SELECT ID, OtherID FROM tblMANYTOMANY WHERE OtherID=65
and then fill a datatable based on that and for each row found in datatable, check the corresponding item in the listbox. Although you mentioned that modifying the query wasn't the first option, this would significantly bring scalability to database operations especially if you plan to upgrade to server side database such as SQL Server
Hope this helps,
Mika
|
|
|
|
|
Hi Mika, unfortunately that didn't work.
To make it easier, and forgetting database access for a while, I can narrow it down to the following issue. Hopefully this might help you to find the root of the problem, and to identify where I'm going wrong!!!
The problem is that I have searched through the listbox properties, and cannot find a way of getting the tags from each of the items in a listbox through a FOR loop. What I would like to do is something like this:
Dim i as integer = 0<br />
<br />
For i = 0 to (MyListBox.items.count - 1)<br />
<br />
' Attempt 1 - doesn't work (Tag isn't a property of Items anyway)<br />
<br />
msgbox("The tag in this item is: " & MyListBox.Items.Tag(i))<br />
<br />
' Attempt 2 - doesn't work either (Tag is a property of the listbox, but it<br />
does not seem to like being treated as an "array")<br />
<br />
msgbox("The tag in this item is: " & MyListBox.Tag(i))<br />
<br />
Next
In both cases, the application compiles but returns an error message: "If a member in a class library has been removed, recompile any assemblies that reference that library". I am not certain what this means, but I'm guessing it is the fact that listboxes don't like their items being treated as "arrays".
I have also changed i = 0 to i = 1 in the forlorn hope that the listbox started at 1 rather than 0, but with no luck.
I'm sure there are ways around this, but I don't want to write pages of extra code if I'm just missing one line...
Thanks again, I really appreciate it!
|
|
|
|
|
I should also point out that it's a CheckedListBox, not a ListBox (hence the "checks")
|
|
|
|
|
Hi,
I've managed to fix this problem, after much gnashing of teeth...
Basically, for anyone else who runs into the same problem, here is a simple example showing how tags for items in a checkedlistbox can be displayed:
Dim n as Integer<br />
<br />
Dim str as String = ""<br />
<br />
For n = 0 to (MyCheckedListBox.Rows.Count - 1)<br />
<br />
str = str & MyCheckedListBox.Items(n)("MyTag").ToString() & " "<br />
<br />
Next<br />
<br />
Messagebox.show(str)
This assumes you have set up the tag for the item somewhere else in your code, e.g. if it's from a datatable:
MyCheckedListBox.DataSource = dtMyDataTable<br />
MyCheckedListBox.DataBindings.Add("Tag", dtMyDataTable, "MyTag")<br />
MyCheckedListBox.DataBindings.Add("Text", dtMyDataTable, "MyText")<br />
MyCheckedListBox.DisplayMember = "MyText"
To be honest, this seems a very clunky way of doing things, but that's just my opinion!
|
|
|
|
|
Doesn't seem so clunky at all.
As you noticed the problem in your previous post was that you didn't use the indexer on Items, but tried to use it on Tag property (which won't work since you are not "positioned" to any single Item).
Glad you got it solved.
Mika
|
|
|
|
|
hi to everybody, I would need an information please.
I need to distribute an application on a pendrive and
my customer doesn't want to make installations
but the problem is that I must give him a report and
I cannot use the cristal report viewer because it asks for the dll to install.
if I use the control "rdlc" for the construction of the report,
as do I do to show it without bringing me behind particular dll?
thanks for the help and good day
|
|
|
|
|
You simply don't have a choice. You either make an installation, as required by whatever reporting package you use, or you leave out the reporting. It's that simple.
|
|
|
|
|
I declared a variable name as string
I populate my combo in the selected indexchanged event
i have name = me.combox.selecteditem tostring
the name is returning system.data.datarowview
Any idea why is returning system.data.datarowview type instead of assigning
the selected name to the name variable.
|
|
|
|
|
I am confused.
Post your code please.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Sub listsponsor()
Me.CmbSponsor.DataSource = objreg.listsponsor
Me.CmbSponsor.DisplayMember = "distID"
Me.CmbSponsor.ValueMember = "distID"
End Sub
Private Sub CmbSponsor_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbSponsor.SelectedIndexChanged
Me.txtsponsorformno.Text = objreg.getsponsorformno(Me.CmbSponsor.SelectedItem.ToString)
End Sub
Me.CmbSponsor.SelectedItem.ToString returns system.data.datarow view. i also notice on step into that selectedindexchange fire bfore line 2 in sub listsponsor
|
|
|
|
|
Ebube wrote: Me.CmbSponsor.SelectedItem.ToString returns system.data.datarow view
Its due to the fact that your ComboBox is Databound.
Use SelectedText instead.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|