vb.net connects to database access - vb.net

im really new to this language so this is so simple please answer
Me.InfoBindingSource.RemoveCurrent()
i only have id t on my delete button do i have to adsome codes? knows anyone?
i've searched some sites and it is the only code they say. i connected it and actually worked on add. but with delete it dont.
Do i need to move something.. like files?
i've tried everything this is my last hope. thanks for the answer :)
here is the whole code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.InfoBindingSource.RemoveCurrent()
End Sub

That RemoveCurrent method will mark the current row in the bound DataTable as Deleted. Just like when adding or editing rows though, you still have to call Update on your data adapter or table adapter to save that change back to the database.

Related

How should I reset my application using vb2008 except for the last form?

So, I made an application which composes several forms. It contains saving scores at the end of the game(form). However, when I try to reset the game, it resets all the data with this code:
Private Sub ResetDataToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetDataToolStripMenuItem.Click
Application.Restart()
Me.Refresh()
I only want to reset all forms except for the scoretable form which is the last form. Can you give me the easiest way to solve my problem?
P.S I am a newbie for this. Please help me guys. This will serve as my quarterly exam. I need to pass.

Using VB.net DataGrid view to interact with SQL DB. Update/Delete/Add

Setup Information
I have "Form1" with a DataGrid View ("DataGridView1") which populates with Data from an SQL server table.
It's a simple table, with about 10 records.
The table used is "jamesTestVBlol"
The dataset is named "DataSetJames.xsd"
I believe the table adaptor is called "JamesTestVBlolTableAdaptor"
Question
Is there a way, I can update a record and send these changes back to the server.
e.g. Column 1, record 1 I would like to change to "TEST" and update this table on the server.
The only code I have is:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DataSetJames.jamesTestVBlol' table.' You can move, or remove it, as needed.
Me.JamesTestVBlolTableAdapter.Fill(Me.DataSetJames.jamesTestVBlol)
End Sub
End Class
Could anyone help me with where I need to look?
I've tried to read several online tutorials, but generally they are above my head.
Thanks,
James.

Focused row not working - Gridview

I am using Dev Express to develop a form in which i have a GridControl with a View inside a View.
It looks like this:
I am then trying to use the event ValidatingEditor to validate the user input.
I tried to do that by doing:
Private Sub grvObsAM_Artigos_ValidatingEditor(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs) Handles grvObsAM_Artigos.ValidatingEditor
Dim row As Integer = Me.grvObsAM_Artigos.FocusedRowHandle
This, however always returns me something like -99999..
I poked around and tried this other solution using the sender from the event:
Private Sub grvObsAM_Artigos_ValidatingEditor(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs) Handles grvObsAM_Artigos.ValidatingEditor
Dim grv As DevExpress.XtraGrid.Views.Grid.GridView = CType(sender, DevExpress.XtraGrid.Views.Grid.GridView)
Dim row As Integer = grv.FocusedRowHandle
And using this second solution i managed to get the focused row handle. Even though this worked this time (because the event was triggered by the view itself and i had access to the sender) this doesn't solve my problem as there are other events where the sender is not the view and the problem persists.
Usign Me.grvObsAM_Artigos."insert anything here" doesn't seem to work properly.
Does anyone have any idea on why this is happening? Am i missing something?
Regards,
I think your issue is actually that you have several of the grvObsAM_Artigos gridviews. One for each row that has the details. So you need to use the view above ti to access the proper one. Using:
Dim grv as XtraGrid.Views.Grid.GridView = grvObsAM.GetDetailView(RowHandle, 0)
That should give you the right instance of the gridView you want. Everytime a master row is expanded and collapsed, the child is created and destroyed respectively.
This should give you a bit more background.
http://documentation.devexpress.com/#WindowsForms/DevExpressXtraGridViewsGridGridView_GetDetailViewtopic

When I call the clear method for a ListView object, the column headers disappear - VB.Net

Good day, I've just started teaching myself VB.net. I'm trying to create a simple note keeping program.
I've come across a problem, where by I call the Clear method of the ListView object, and its column headers disappear.
screen shot of what happens
The code for button 2 is:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
lstNotes.Clear()
End Sub
Any help will be appreciated, thanks!
The Clear method on a listview does exactly that. Just as advertised.
Use lstNotes.Items.Clear() instead.
Augh, as luck would have it, I got the answer Just after posting.
lstNotes.Items.Clear()
use Items.clear() instead!
lstNotes.Items.Clear()

Dynamic dropdown based on Radio selection

Good morning all! Myself and a co-worker are tasked with a system-wide scripting solution but neither of us are .NET programmers so we need your help.
We have a GUI that displays a radio selection box (3 options) that are the three sites where our hospitals are. We need to dropdown located on the form to fill with only the locations based on the selected radio option.
my gui http://web6.twitpic.com/img/40330741-85d91a5637f2445b322e62df17cf3351.4aef01c5-full.jpg
Here is the code behind we have so far (sorry, VB)
Public Class frmCEHLI
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'CELocDataSet.dbo_Locations' table. You can move, or remove it, as needed.
Me.Dbo_LocationsTableAdapter.Fill(Me.CELocDataSet.dbo_Locations)
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
MsgBox("Submit button has been pressed")
End Sub
End Class
For the record the Location dropdown is currently databound but its a static SELECT statement which brings us all the locations but we'd prefer it to be cleaner if it only returned the locations based on Site. We are using Visual Basic 2008 Express Edition for development. Any help/code is appreciated, thanks!
Sorry not to respond back sooner, busy, and wanted to dig up a sample that did just what you were needing.
Create two comboboxes on your form. You can bind either fixed values, or from a table on the first combo. Then, from the property/events sheet, first set the "AutoPostBack" to TRUE, then on the events, click for the "SelectedIndexChanged" event to bring up some code.
The "Sender" object parameter will be the combobox itself, so you'll be able to analyse the property settings via debugging to find what key/value was chosen.
Then, run whatever query from your data querying control, business object, or whatever that gets your results, such as to a DataSet or DataTable.
Finally, set the datasource of your second combo to the above result query, set dataTextField and DataValueField and issue DataBind() to the combo.
That should get exactly what you need.
Then, when someone makes a selection from the second combo, you can have code within ITS "SelectedIndexChanged" event (also based on its AutoPostBack or actual submit button on the form).
Hope this helps.
I would create two combobox controls... One for the "where", then, on the InteractiveChange event by the user to post-back to the page using that answer for the second combobox of locations based on the "where" value of the first combo.