|
I want my dataGrid's DataSource to be a Query from my MSAccess Database, but I can only put a DataTable from a DataSet as the DataSource. Is there an other way that the DataSource can be linked with my Query?
(...too many "data" in this question...)
Thanks!
|
|
|
|
|
You can put the DataSet as a DataSource, then the DataMember property should be the name of a table in the DataSet.
|
|
|
|
|
That's what I'm doing right now, but I don't want the DataMember to be a table but rather a query. Is there a way to to this?
The reason I want to do that is because I need to do operations in the grid, but I really don't know how. That's why I did a Query in MSAcces, but I can't use it as a dataSource for the grid.
|
|
|
|
|
You should probably look for a good book on interacting with VB and databases.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
ford86 wrote: That's what I'm doing right now, but I don't want the DataMember to be a table but rather a query. Is there a way to to this?
No, there isn't. Any query is going to return the results in either a DataSet (multiple tables) or a DataTable object. If your query is returning data from a single table, you can keep it in a DataTable and bind the DataGridView to that.
ford86 wrote: That's why I did a Query in MSAcces, but I can't use it as a dataSource for the grid.
Of course you can!! The exact same query is going to return results in a DataTable or DataSet.
Seriously, you need to pickup a book on VB.NET and/or ADO.NET and work through it.
|
|
|
|
|
Hi,
You can assign a join query to DataAdapter, fill the DataSet, Create a DataView and link it to the table, apply filter on the RowFilter Property of DV
Private DS As New DataSet
Private DA As SqlClient.SqlDataAdapter
Private DV As DataView
...
Dim ConnString As String = "Data Source...."
DA = New SqlClient.SqlDataAdapter("SELECT ... FROM Table1 INNER JOIN Table2 ON ...", ConnString)
DA.Fill(DS, "TwoTables")
DV = New DataView(DS.Tables("TwoTables"))
dg.DataSource = DV
...
DV.RowFilter = "ID = 2" ' > < <> ...
Note: Update here has some restrictions!
hope this helps
|
|
|
|
|
Not sure if you can use SqlDataAdapter on Access databases. That is for SQL Server....
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Is there a better way to update a datagrid then connection to table and running a update() method to check the database and fill the dataset every 5 secounds?
|
|
|
|
|
You could create a data layer that all database access goes through. When the data layer is told to update a record it could also fire off an event that your UI code subscribes to. This event would tell the UI code that a record has changed and also possibly get a DataRow object passed to it containing the changed record.
Just a thought. I have no example code and don't know of any.
|
|
|
|
|
Hi
I need to subclass ( in C++ ) Command Prompt window but CP window's WndProc is Zero , therefore i can not call DefWndProc
Thanks for your ideas
|
|
|
|
|
Ky Nam wrote: I need to subclass ( in C++ ) Command Prompt window but CP window's WndProc is Zero , therefore i can not call DefWndProc
Thanks for your ideas
It might be an idea to post this in a C++ related forum. I don't think you'll get an answer in the VB forum.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Ky Nam wrote: I need to subclass ( in C++ ) Command Prompt window but CP window's WndProc is Zero
Of course! A console app doesn't have a message pump, so won't have a WndProc function.
|
|
|
|
|
I have a multi-line textbox similar to the interface of a graphing calculator. I added a scrollbar so the user doesn't have to clear the screen every time it is full but the scrollbar remains locked at the top, requiring the user to scroll down to see what he or she is typing. How can I either make the scrollbar lock to the bottom or make the text box "toss" the top lines?
Thanks!
Natalie
|
|
|
|
|
Try setting TextBox.SelectionStart=TextBox.TextLength and using TextBox.ScrollToCaret method
|
|
|
|
|
Ky Nam wrote: Try setting TextBox.SelectionStart=TextBox.TextLength and using TextBox.ScrollToCaret method
Thanks for the input but this didn't quite work. It is still staying at the top of the textbox. I have a virtual keyboard on the form and it is the only way to input text to the textbox (unfortunately it is supposed to be designed this way) so the caret does not follow the text as it is entered. How can I get the caret to behave like there is input from the keyboard?
-- modified at 13:27 Wednesday 25th July, 2007
|
|
|
|
|
ScrollToCaret only works if the TextBox you call it on has the input focus.
|
|
|
|
|
I tend to do this with a ListBox; adding a line becomes (in C#):
lb.Items.Add(s);
lb.TopIndex=lb.Items.Count-1;
|
|
|
|
|
First the program i'm creating is to let users upload a file and placed it in a treeview.
I'm trying figure out how to take an uploaded text file from the form and place it in the treeview???
|
|
|
|
|
You'll have to open this file and read it yourself, parsing each line and taking appropriate action depending on how you want the treeview populated. There is nothing that will populate the treeview from any textfile automatically.
|
|
|
|
|
Ok, well I plan to rename the file by taking the file name that the users input into a textbox and placed that name in the treeview and when that node is click it should display the content of the file. Any other suggestion or examples would be greatly appreciated.
|
|
|
|
|
Than add the node to the TreeView where you want it and add put the full path to that file in the Tag property of the Node. Handle the NodeMouseClick event and get the Node that was clicked out of the event args. You can get the full path of the file out of the Tag event, and the rest is up to you.
|
|
|
|
|
I want to reuse some code this piece of code once:
<code> Try
If txt78.Text.Length = 0 Then
Call LabelCheck(78)
Else
If txt78.Text.Length <> 0 Then
Call UpdateMath(78)
If cm_intCompare78 <> txt78.Text Then
Call UpdateQuery(78)
If intCurrentCount >= 1000 Then
cm_intCompare78 = intCurrentCount - 1000
Else
cm_intCompare78 = intCurrentCount
End If
End If
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try</code>
But the issue is that i have use this piece of code 14 times. What i would like to is something like this:
dim strTime as string
Try
If txt & strTime &.Text.Length = 0 Then
Call LabelCheck(strTime)
Else
If txt78.Text.Length <> 0 Then
Call UpdateMath(strTime)
If cm_intCompare & strTime <> txt & strTime &.Text Then
Call UpdateQuery(strTime)
If intCurrentCount >= 1000 Then
cm_intCompare & strTime = intCurrentCount - 1000
Else
cm_intCompare & strTime = intCurrentCount
End If
End If
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
In thoery this should work but doesnot.. I have tryed to us string.concat but it doesnot work. Does anyone have any Ideas how i can do this?
Thank you
Shane
-- modified at 12:47 Wednesday 25th July, 2007
|
|
|
|
|
Since you are new, please read the forum guidelines. Your message titles need to have meaning. Using words like 'help' or 'urgent' may get your question ignored as we have had a rash of them lately.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
Sorry, about that..i will read it more carefully next time..
Shane
|
|
|
|
|
Jeffrey Shane wrote: If txt & strTime &.Text.Length = 0 Then
This is not going to work.
So put this code into its own Sub and pass the textbox as a parameter to it, not the string in the textbox.
|
|
|
|