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.
3 2805
First, try the .Refresh/.Requery of the data source to see if the grid is updated correctly with the new information. That is if the binding source as you call it is not used for the insert stored procedure. If it is, then you need to close and rebind the data source to execute the query stored procedure.
Good Luck
I have posted my code with any sensitive info uniformly modififed. I'd appreciate it if you, or anyone, could point out what I'm doing wrong, or not doing right, or both. - ===========
-
-
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
-
-
#################################
I'm using Visual Studio 08 and I've been leaning on the GUI so if there are code elements that don't make sense please let me know. I'm trying to learn this as fast as I can, I'm just not learning how to fix this particular item fast enough.
Well now that I see that you are NOT using Visual Basic 6.0 BUT are using VB.NET! I would suggest that you look to the right of your original post.... now do you see where it says vb.net???? That would be the place for your question...
Good Luck
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...
|
by: BigD |
last post by:
This all centers around an Access Data Project
I have a stored procedure that aggregates events stored in a table
based on intervals I specify. I have a form that supplies parameters
for the...
|
by: Not Me |
last post by:
Hey,
Coming back to a piece of work I did a while back, which used a stored
procedure to populate a list box. The SP takes a single parameter, and
I think this is the reasoning for using 'exec'...
|
by: Dino L. |
last post by:
How can I run stored procedure (MSSQL) ?
|
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...
|
by: Rich |
last post by:
I have a stored procedure on Sql Server2k. I can fill a data table which I
can append to a dataset using an ADODB recordset object which gets populated
from a command object that runs the sp. I...
|
by: Frawls |
last post by:
Hi
I Am am having problems with a stored Procedure that i wrote.
Basically whats happening is that the Stored procedure Runs fine when i
EXECUTE it in SQL Query analyzer.
But when i debug...
|
by: Orit |
last post by:
Hi .
I am creating an ASP.NET 2.0 web site and have the following problem :
1. I have a GridView which bound to the object data source.
2. This object data source is SQL Table adapter that I...
|
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...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |