473,769 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Save Changes in VB.NET 2005 with Access 2003 --- Not using any Binding Navigator

Hi Guys

I have got 3 tables -[Personal Details, Course, Picture] in Access
Database with Student ID as primary Key in all and all tables are
linked with 1 to 1 relationship.

I have code the everying with manual program to access information of
tables on Windows Form. It is working properly. i can see all the
records properly.

I am not using Data Binding Navigator.

I have created SAVE Button on Form and i want that button to update
data/records in main database. [ If i change student Addess on form
then with SAVE Button click event, i want that to update in database]

Can you tell me how i can do it. i have been trying for so many weeks.

Please do help me.

here is the code of the form which is working properly at displaying
data from DB.

""""""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""

Imports System.Data

Public Class ExistingStudent Form
Dim dt As New DataTable
Dim rowIndex As Integer = 0

Private Sub btnBack_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s)
Dim frmMenu As New Menu

frmMenu.Show()
Me.Hide()

End Sub

Private Sub PicUpload_Click (ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles PicUpload.Click
OpenFileDialog1 .InitialDirecto ry = "F:\Ankit\Tames ide College _
HND Year 1\Unit 7_Visual Basic.NET\SIRS_ Use THIS ONE\Photos"
OpenFileDialog1 .ShowDialog()
OpenFileDialog1 .Filter =
"Bitmaps(*.bmp) |*.bmp|JPEG(*.j pg)|*.jpg|GIF(* .gif)|*.gif"

picperson.Image = Image.FromFile( OpenFileDialog1 .FileName)
picperson.SizeM ode = PictureBoxSizeM ode.CenterImage

End Sub
Sub updateTextBoxes ()
txtStudentID.Te xt =
CStr(dt.Rows(ro wIndex)("Person alDetail.Studen tId"))
txtStudentName. Text = CStr(dt.Rows(ro wIndex)("Name") )
txtAddress.Text = CStr(dt.Rows(ro wIndex)("Addres s"))
txtTown.Text = CStr(dt.Rows(ro wIndex)("Town") )

txtCourse.Text = CStr(dt.Rows(ro wIndex)("Course Name"))
txtDoB.Text = CStr(dt.Rows(ro wIndex)("DOB"))
txtSex.Text = CStr(dt.Rows(ro wIndex)("Sex"))
txtTelephone.Te xt = CStr(dt.Rows(ro wIndex)("Teleph one"))
txtContactName. Text = CStr(dt.Rows(ro wIndex)("Contac tName"))
txtContactNo.Te xt = CStr(dt.Rows(ro wIndex)("Contac tNumber"))
picperson.Image =
Image.FromFile( CStr(dt.Rows(ro wIndex)("FilePa th")))

End Sub

Private Sub ExistingStudent Form_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load

Dim constr As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=C:\Docum ents and Settings\Ankit\ Desktop\Tamesid e College _ HND
Year 1\Unit 7_Visual Basic.NET\SIRS_ Use THIS ONE\Student
Database\Studen ts.mdb"

Dim SqlStr As String = "SELECT PersonalDetail. *, Course.*,
Picture.* FROM (PersonalDetail INNER JOIN Picture ON
PersonalDetail. StudentId = Picture.Student Id) INNER JOIN Course ON
PersonalDetail. StudentId = Course.StudentI d"

Dim dataAdapter As New OleDb.OleDbData Adapter(SqlStr, constr)

dataAdapter.Fil l(dt)
dataAdapter.Dis pose()
updateTextBoxes ()
End Sub

Private Sub btnPrevious_Cli ck(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles btnPrevious.Cli ck
If (rowIndex 0) Then
rowIndex = rowIndex - 1
updateTextBoxes ()
End If
End Sub

Private Sub btnNext_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnNext.Click
If (rowIndex < dt.Rows.Count - 1) Then
rowIndex += 1
updateTextBoxes ()
End If
End Sub
Private Sub btnSearch_Click (ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles btnSearch.Click
Dim studentid As String

Dim studentFound As Boolean = False

studentid = InputBox("Enter Student ID")
For i As Integer = 0 To (dt.Rows.Count - 1)
If CStr(dt.Rows(i) ("personalDetai l.StudentId") = studentid)
Then
studentFound = True
rowIndex = i
updateTextBoxes ()
End If
Next

If (Not studentFound) Then
MsgBox("System Cannot find requested Student Information",
0, "Not in Table")
End If
End Sub
Private Sub btnSave_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSave.Click




End Sub
End Class

""""""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """""""""
Thanks.

Do reply either here or send me e mail me at
an************* ***@yahoo.com / an***********@g mail.com

Cheers.

Nov 18 '06 #1
1 2927
Ankz,

What is the advantage in your idea from a 1 to 1 relation instead of just
set it in the datarow

Now you need at least 9 datatable accesses to do an update.

Cor

"ankz" <an***********@ googlemail.coms chreef in bericht
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hi Guys

I have got 3 tables -[Personal Details, Course, Picture] in Access
Database with Student ID as primary Key in all and all tables are
linked with 1 to 1 relationship.

I have code the everying with manual program to access information of
tables on Windows Form. It is working properly. i can see all the
records properly.

I am not using Data Binding Navigator.

I have created SAVE Button on Form and i want that button to update
data/records in main database. [ If i change student Addess on form
then with SAVE Button click event, i want that to update in database]

Can you tell me how i can do it. i have been trying for so many weeks.

Please do help me.

here is the code of the form which is working properly at displaying
data from DB.

""""""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""

Imports System.Data

Public Class ExistingStudent Form
Dim dt As New DataTable
Dim rowIndex As Integer = 0

Private Sub btnBack_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s)
Dim frmMenu As New Menu

frmMenu.Show()
Me.Hide()

End Sub

Private Sub PicUpload_Click (ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles PicUpload.Click
OpenFileDialog1 .InitialDirecto ry = "F:\Ankit\Tames ide College _
HND Year 1\Unit 7_Visual Basic.NET\SIRS_ Use THIS ONE\Photos"
OpenFileDialog1 .ShowDialog()
OpenFileDialog1 .Filter =
"Bitmaps(*.bmp) |*.bmp|JPEG(*.j pg)|*.jpg|GIF(* .gif)|*.gif"

picperson.Image = Image.FromFile( OpenFileDialog1 .FileName)
picperson.SizeM ode = PictureBoxSizeM ode.CenterImage

End Sub
Sub updateTextBoxes ()
txtStudentID.Te xt =
CStr(dt.Rows(ro wIndex)("Person alDetail.Studen tId"))
txtStudentName. Text = CStr(dt.Rows(ro wIndex)("Name") )
txtAddress.Text = CStr(dt.Rows(ro wIndex)("Addres s"))
txtTown.Text = CStr(dt.Rows(ro wIndex)("Town") )

txtCourse.Text = CStr(dt.Rows(ro wIndex)("Course Name"))
txtDoB.Text = CStr(dt.Rows(ro wIndex)("DOB"))
txtSex.Text = CStr(dt.Rows(ro wIndex)("Sex"))
txtTelephone.Te xt = CStr(dt.Rows(ro wIndex)("Teleph one"))
txtContactName. Text = CStr(dt.Rows(ro wIndex)("Contac tName"))
txtContactNo.Te xt = CStr(dt.Rows(ro wIndex)("Contac tNumber"))
picperson.Image =
Image.FromFile( CStr(dt.Rows(ro wIndex)("FilePa th")))

End Sub

Private Sub ExistingStudent Form_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load

Dim constr As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=C:\Docum ents and Settings\Ankit\ Desktop\Tamesid e College _ HND
Year 1\Unit 7_Visual Basic.NET\SIRS_ Use THIS ONE\Student
Database\Studen ts.mdb"

Dim SqlStr As String = "SELECT PersonalDetail. *, Course.*,
Picture.* FROM (PersonalDetail INNER JOIN Picture ON
PersonalDetail. StudentId = Picture.Student Id) INNER JOIN Course ON
PersonalDetail. StudentId = Course.StudentI d"

Dim dataAdapter As New OleDb.OleDbData Adapter(SqlStr, constr)

dataAdapter.Fil l(dt)
dataAdapter.Dis pose()
updateTextBoxes ()
End Sub

Private Sub btnPrevious_Cli ck(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles btnPrevious.Cli ck
If (rowIndex 0) Then
rowIndex = rowIndex - 1
updateTextBoxes ()
End If
End Sub

Private Sub btnNext_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnNext.Click
If (rowIndex < dt.Rows.Count - 1) Then
rowIndex += 1
updateTextBoxes ()
End If
End Sub
Private Sub btnSearch_Click (ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles btnSearch.Click
Dim studentid As String

Dim studentFound As Boolean = False

studentid = InputBox("Enter Student ID")
For i As Integer = 0 To (dt.Rows.Count - 1)
If CStr(dt.Rows(i) ("personalDetai l.StudentId") = studentid)
Then
studentFound = True
rowIndex = i
updateTextBoxes ()
End If
Next

If (Not studentFound) Then
MsgBox("System Cannot find requested Student Information",
0, "Not in Table")
End If
End Sub
Private Sub btnSave_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSave.Click




End Sub
End Class

""""""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """"""""""""""" """""""""
Thanks.

Do reply either here or send me e mail me at
an************* ***@yahoo.com / an***********@g mail.com

Cheers.

Nov 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1746
by: Kevin G. Anderson | last post by:
What: CAUG Meeting - Visual Studio 2005 Tools for Office When: Thursday, April 27, 2006, 6PM Who: Jacob Cynamon, Microsoft Where: The Information Management Group 200 W. Monroe St. Suite 900 Chicago, IL 60606 (312) 222-9400 Location: www.imginc.com/IMG/About+IMG/chicago.htm info@caug.com and add "ATTENDING" to the subject
0
1124
by: vishalsangwan | last post by:
Hi Everybody, I am writing an application using the bindingnavigator and the oledbDataAdapter. I am not able to save the changes to the actual access database. Please help me. The code follows. Thank you Vishal I have opened a connection and the following code binds the database with the bindingnavigator using a oledbDataAdapter. And also to the text box. Where we can edit the fields and later on save them.
1
1519
by: vishalsangwan | last post by:
Hi Everybody, I am writing an application using the bindingnavigator and the oledbDataAdapter. I am not able to save the changes to the actual access database. Please help me. The code follows. Thank you Vishal I have opened a connection and the following code binds the database with the bindingnavigator using a oledbDataAdapter. And also to the text box. Where we can edit the fields and later on save them.
7
5355
by: bhavin30 | last post by:
Is there a way to obtain user information (using LOGON_USER server variables) when you have set up the security to Anonymous Access? I have tried setting the security to both Anonymous + Window Integrated, without any luck. I'm using IIS 6.0 on Windows Server 2003 Thanks in advance!
2
3298
by: Randy | last post by:
Hi, I'd like to add a new blank record to a form for the user to input data. What I am trying to do is exactly what the + on the binding navigator does, with some additional steps involved. So, my question can be asked from two directions: 1. Is the binding navigator code visible somewhere? If it is, I'll just copy it from there into my procedure. 2. What is the code that the binding navigator uses to add this blank row without...
2
10087
by: Randy | last post by:
Hi, I'm trying to figure out some binding navigator code. If I have the primary field value as selected by the user in a combo box, how can I instruct the binding navigator to move to that record. Here is what I have so far: Dim strSQL As String strSQL = "SELECT OrderID WHERE OrderID = @OrderID" Dim cmdSelect As New SqlCommand(strSQL, cn) cmdSelect.Parameters.AddWithValue("@OrderID, cboOrderID.text)
1
2526
by: Robert Dufour | last post by:
Vs2005, .Net 2.0, vb.Net, Winforms I have a form with a binding source, a binding navigator, a table adapter and a dataset (all using sql 2005 same table, to keep it simple) When the user tries using next, previous, first or last, or closes the form I would like to automatically detects if any changes were made and if so do an update. If the update was unsuccessful, user should not be allowed to navigate nor close the form until problem...
2
1442
by: jehugaleahsa | last post by:
Hello: We are running into an issue. Whenever our users save using either the save key or a BindingNavigator, whatever control is in focus won't be updated. Our users are getting confused when they are asked whether they want to save their changes. Is there a way to force the the control changes to be accepted prior to saving? Is there an easy way to add this to all of our code?
2
994
by: =?Utf-8?B?RWR3YXJk?= | last post by:
Hi everybody I'm usuing the walkthrough example in MSDN , I successfully created a SQL database and I can retrieve my data in my application using bound controls and Binding navigator but when I save something i the datebase and close the application and then open it again all the new data i have saved are gone. Even I added the code in my formclosing event Me.AddressesBindingSource.EndEdit()...
0
10210
Oralloy
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...
0
10039
jinu1996
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...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6668
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();...
0
5297
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...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
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
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.