I've got a database that I've been working on for over a year and a half but I've just recently finished the back end to the point of feeling comfortable with starting on a front end.
So while I've been able to pick up a great deal just stumbling through on my own with the several apress books I've gotten a hold of I've figured out a great deal and have some half decent forms for data entry but for the life of me I can't figure out how to get the databinding to do whatever it does again after having entered data into the database.
My problem placed more concisely
My form's data grid populates from a stored procedure via a binding source.
My form's button then uses another stored procedure to enter in the data into the database.
What I want to do is have the datagrid recall the stored procedure and refresh the grid with the newly modified data included.
This is what I've been racking my brain over for some time, and scouring the internet and my various apress books for, is figuiring out why none of my attempts at doing this are working.
I'm just finding most all of the stuff out there about datagrids and the such are not at all tailored towards a person trying to do all their interactions via stored procedures. I know I can do the basics, and the forms work and I know that if I just close the form and access it manually again that the datagrid reloads with the newly input data, but I'm really trying to get it so that I'm making a UI that is as easy to use as I can get it. - Imports System
-
Imports System.Data
-
Imports System.Data.SqlClient
-
-
-
Public Class WholeAppleInsertion
-
-
' This form is for entering Apple Names with their corresponding
-
' Type. I'm presently trying to get it to work where after submitting
-
' the new name that the data grid will reset itself via calling upon the
-
' stored procedure originally used to populate the grid so that it can
-
' repopulate it, giving an updated view to the user
-
-
-
-
Private Sub WholeAppleInsertion_Load( _
-
ByVal sender As System.Object, _
-
ByVal e As System.EventArgs) _
-
Handles MyBase.Load
-
'TODO: This line of code loads data into the 'VaedaAlefDataSet1.spSelectallWholeApple' _
-
' table. You can move, or remove it, as needed.
-
Me.spSelectallWholeAppleTableAdapter1.Fill(Me.VaedaAlefDataSet1.spSelectallWholeApple)
-
-
Me.spSelectAppleTypeTableAdapter.Fill(Me.VaedaAlefDataSet.spSelectAppleTypeTableAdapterType)
-
-
Me.spSelectallWholeAppleTableAdapter.Fill( _
-
Me.VaedaAlefDataSet.spSelectallWholeApple)
-
-
End Sub
-
-
-
-
' This is the data grid that holds the list of Apple names with their types
-
' that are found in the database. THIS is the data grid that I want to get to
-
' update, to refresh, or however you'd say it, whenever the button is pushed.
-
-
Private Sub DataGridView1_CellContentClick( _
-
ByVal sender As System.Object, _
-
ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
-
Handles DataGridView1.CellContentClick
-
-
End Sub
-
-
-
-
'########THIS IS THE BUTTON CLICK EVENT I WANT TO
-
'########TRIGGER THE REFRESHING OF THE DATAGRID
-
-
Public Function EnterApple_Click( _
-
ByVal sender As System.Object, _
-
ByVal e As System.EventArgs) As SqlDataReader _
-
Handles EnterApple.Click
-
-
-
Using sqlconn As New SqlConnection
-
Dim retval As Integer
-
-
sqlconn.ConnectionString = "Data Source=SQUASHERZ-PC\SQLEXPRESS;Initial Catalog=VaedaAlef;Integrated Security=True"
-
sqlconn.Open()
-
-
Dim sqlComm As New SqlCommand
-
sqlComm.Connection = sqlconn
-
sqlComm.CommandType = CommandType.StoredProcedure
-
sqlComm.CommandText = "spInserlectWholeApple"
-
-
Try
-
sqlComm.Parameters.Add("@Name", SqlDbType.VarChar)
-
sqlComm.Parameters.Add("@Type", SqlDbType.SmallInt)
-
sqlComm.Parameters("@Name").Direction = ParameterDirection.Input
-
sqlComm.Parameters("@Name").Value = TxtAppleName.Text
-
sqlComm.Parameters("@Type").Direction = ParameterDirection.Input
-
sqlComm.Parameters("@Type").Value = ParameterDirection.Input = ComboBox1.SelectedValue
-
-
retval = sqlComm.ExecuteNonQuery()
-
Catch Sqlex As SqlException
-
MessageBox.Show(Sqlex.Message)
-
End Try
-
-
-
TxtAppleName.Text = ""
-
-
-
If retval >= 1 Then
-
MsgBox("something happened")
-
-
-
End If
-
-
-
' //Here below are my attempts at getting this to refresh
-
' //It likely makes it clear that I don't know what I'm doing
-
' PLEASE HELP!
-
-
Me.WholeAppleInsertion_ResetBindings()
-
-
Me.spSelectallWholeAppleBindingSource1.ResetItem(0)
-
-
Me.DataGridView1.Refresh()
-
-
sqlconn.Close()
-
-
End Using
-
-
-
End Function
-
-
-
-
Private Sub TextBox1_TextChanged( _
-
ByVal sender As System.Object, _
-
ByVal e As System.EventArgs) _
-
Handles TxtAppleName.TextChanged
-
-
End Sub
-
-
Private Sub ComboBox1_SelectedIndexChanged( _
-
ByVal sender As System.Object, _
-
ByVal e As System.EventArgs)
-
-
-
End Sub
-
-
Private Sub ComboBox1_SelectedIndexChanged_1( _
-
ByVal sender As System.Object, _
-
ByVal e As System.EventArgs) _
-
Handles ComboBox1.SelectedIndexChanged
-
-
End Sub
-
-
-
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, _
-
ByVal e As System.ComponentModel.DoWorkEventArgs) _
-
Handles BackgroundWorker1.DoWork
-
-
End Sub
-
-
Private Sub spSelectallWholeAppleBindingSource1_CurrentChanged _
-
(ByVal sender As System.Object, _
-
ByVal e As System.EventArgs) _
-
Handles spSelectallWholeAppleBindingSource1.CurrentChanged
-
-
End Sub
-
'This sub is the binding source that retrieves the data for the data grid
-
'This is what I'm trying to figure out how to get it to refresh so that the data
-
'grid displays the new information whenever a new name is submitted via the 'submit
-
'new button' button.
-
Private Sub spSelectallWholeAppleBindingSource_CurrentChanged _
-
(ByVal sender As System.Object, _
-
ByVal e As System.EventArgs) _
-
Handles spSelectallWholeAppleBindingSource.CurrentChanged
-
-
-
End Sub
-
-
-
End Class
3 4473
define a data set then assign the retrieved data to the data set then bind the data to the datagrid.
Me.DataGridView 1.DataSource = Place the dataset here
Me.DataGridView 1.DataBind()
semomaniz,
Well part of what you gave me is doing something and the other part I'm not figuring it out. Heck I may be doing it all wrong. I'm so new I'm not even sure. By placing the first one, the
Me.DataGridView 1.DataSource = Place the dataset here
That makes it so that when I press the button something happens to the DataGridView, it goes empty. Which makes me unsure if I'm following you on this or if I'm doing it right. If there's any way, and I know this is asking more of your time and showing my noobness, but could you please give an example in code as to what you're describing would look like?
Oh, and another problem, and perchance this would vanish if I was doing things correctly, but when I go to do the
Me.DataGridView 1.DataBind()
Visual Studio only wants to do a
Me.DataGridView 1.DataBindings( )
which it then underlines with the blue line thingy and claims (and I'll be honest and say I'm not quite understanding what it's asking for) that "Property access must assign to the property or use its value" and that one just has me even more befuddled.
I'm tickled pink that I was able to get the datagridtable to at least do something. I hope you, or someone, can help me with this.
Thank you again for your time.
Frinavale 9,735
Recognized Expert Moderator Expert
I didn't think that you could bind a DataGridView to a DataSet...
A DataSet contains multiple tables but a DataGridView really should only display one table.
You should set the DataGridView.Da taSource a specific table in the DataSet...not to the DataSet itself.
If you require data to be pulled from multiple tables then you should use the tables within the DataSet to return a View or a new table with the columns you need to display.
Once you have changed the DataSource the DataGridView should display the new source. If not, call the DataBind method...if this still doesn't display the refreshed data also call the DataGridView.Up date() method to repaint the DataGridView.
-Frinny
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: harborboy76 |
last post by:
Hi,
I have a stored procedure that does a lot of INSERT/UDATE to 3
tables. And When I call the stored procedure, I get a Transaction Log
Full error. When I want to do is turning off the transaction log on
those 3 tables that the stored procedure is using.
Now, since I call the stored procedure on the command line (CLI),
where do I run ALTER TABLE ... ACTIVATE NOT LOGGED INITIALLY statement
? Do I have to put them inside the stored...
|
by: Max |
last post by:
Is it possible or more effecient to use a stored procedure to populate a
datagrid when using datagrid or custom paging? Is it (ADO.NET?) pulling the
entire table into the dataset or is it just pulling the page as defined by
the page size?
I'm assuming that if I use a stored procedure with a datagrid, I won't be
able to use the datagrid's paging anyway, and would have to create my own
code in the stored procedure to return each page of...
|
by: Andrew |
last post by:
Hey all,
I am very new to ASP.Net (and .Net in general), but that isn't stopping the
boss from wanting to begin new projects in it. This latest project has me
kinda stumped and after a couple days of struggling, I figure asking you all
(the experts) will keep me from going down some dark and dangerous road.
The project I have is a fairly simple one, in theory anyway. The gist is to
create a page where the user enters an IDNumber,...
|
by: Fred Nelson |
last post by:
I have an application in which it would be VERY beneficial if I could obtain
the names of the colums in a datagrid.
For example
dim datagrid1 as new datagrid
datagrid1.datasource = (stored procedure that loads datagrid)
datagrid1.databind()
I am able to obtain the data in the datagrid by its relative number however
|
by: chreo |
last post by:
Hello.
Does anybody had problem with VB application with MS SQL Database?
I have DATAGRID which shows TABLE from DATABASE.
Next I add new ROW to TABLE with SQLcommand (stored procedure)
Command works everytime - I see in database that new rows are added.
| |
by: Sharon |
last post by:
Hello All,
Is it possible to update Sql Table through DataGrid. I have a DataGrid
which is being populated through a stored procedure, all i wanted to do
is to update one field (FieldName-Authorised) which has a datatype bit
through DataGrid but not sure how to go about it. Any Ideas Guys on
this one, your help is greatly appreciated.
This is the procedure used to populate the datagrid, The primary key
for the table is EntryID which...
|
by: boyindie86 |
last post by:
How can i pull images out of an mysql table and populate the below datagrid. I have all my images stored in an external store, and the addresses are stored in my DB, i am not sure how to pull these addresses out and get it to populate the table. I have the followin ASP code
<code><asp:DataGrid runat=server ID=test AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" Height="343px" Width="551px">...
|
by: peter |
last post by:
I am trying to get a SQL stored procedure to use user maintained MQT
implicitly which raises questions on when they are used or not used.
In theory you would expect the stored procedure to pick up the MQT at
the time it is bound on the creation of the static SQL. This raises
the question on how you stop it or start it using a MQT as there is no
option on the bind. What happens when it is rebound? What happens if
the plan is made invalid...
|
by: Mark B |
last post by:
Can someone write some VB.Net example code for me that does this:
1) Creates a gridview control with the results of a SQL stored procedure
that has 1 parameter (text)
2) Adds an extra column that displays the result of a VB.Net function that
uses a value from an existing column
I have spent 4 hours trying to do this after Googling for examples... There
are many new concepts that I haven't had much experience with...
|
by: FrustratedNoob |
last post by:
I've got a database that I've been working on for over a year and a half but I've just recently finished the back end to the point of feeling comfortable with starting on a front end.
So while I've been able to pick up a great deal just stumbling through on my own with the several apress books I've gotten a hold of I've figured out a great deal and have some half decent forms for data entry but for the life of me I can't figure out how to get...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |