473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with .addnew in vb.net

Working on this piece of code but when i click on my add button in the form the text boxes that i am using do not clear and so i can't add a new record any help
would be great. The code for my data tier and app is below thanks.

Data tier

Public Class VideoData
Public Function getMovies(ByVal strName As String) As DataSet
Select Case strName
Case "Video"
daMovies.Fill(Ds1)
Case "Studio"
daStudio.Fill(Ds1)
End Select
Return Ds1
End Function

Public Sub upDateAll(ByVal ds As DataSet, ByVal strName As String)

Try
Select Case strName
Case "Video"
daMovies.Update(ds)
Case "Studio"
daStudio.Update(ds)
End Select
Catch
Throw
End Try
End Sub

End Class

Application

Public Class frmBrowseMovies
Inherits System.Windows.Forms.Form

Dim objData As VideoData
Dim dsMovies As DataSet
Dim bmMovies As BindingManagerBase

Private Sub frmBrowseMovies_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
objData = New VideoData
dsMovies = objData.getMovies("Video")
bmMovies = Me.BindingContext(dsMovies, "Video")
bindData()
AddHandler bmMovies.PositionChanged, AddressOf Position_Changed
Position_Changed(sender, e)
Catch ex As Exception
End Try
End Sub

Sub bindData()
txtMovieID.DataBindings.Add("Text", dsMovies, "Video.MovieID")
txtTitle.DataBindings.Add("Text", dsMovies, "Video.Title")
txtDirector.DataBindings.Add("Text", dsMovies, "Video.Director")
txtActor.DataBindings.Add("Text", dsMovies, "Video.Actor")
txtActress.DataBindings.Add("Text", dsMovies, "Video.Actress")
txtLength.DataBindings.Add("Text", dsMovies, "Video.Length")
txtPopularity.DataBindings.Add("Text", dsMovies, "Video.Popularity")
txtYear.DataBindings.Add("Text", dsMovies, "Video.Year")
txtCategory.DataBindings.Add("Text", dsMovies, "Video.Category")
txtStudioID.DataBindings.Add("Text", dsMovies, "Video.StudioID")
chkAward.DataBindings.Add("checked", dsMovies, "Video.Awards")
End Sub

Private Sub Position_Changed(ByVal sender As Object, ByVal e As EventArgs)
With bmMovies
lblRecord.Text = "Record " & (.Position + 1) & " of " & .Count
End With
End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

If btnAdd.Text = "Add" Then

unlockTextBoxes()
disableNavigation()
setEditButtons()
bmMovies.EndCurrentEdit()
bmMovies.AddNew()
txtMovieID.Focus()

Else

bmMovies.CancelCurrentEdit()
lockTextBoxes()
enableNavigation()
resetEditButtons()

End If

End Sub
Oct 24 '06 #1
0 3167

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Jan van Veldhuizen | last post by:
I have an application which is running fine with MS SqlServer, but it should be working with Oracle as weel. At a lot of places we rely upon the ADO Recordset to return incremented identity...
0
by: AR Hall | last post by:
This code goes through 3 work sheets in the same XL workbook, day, eve and night shift in each sheet their are columns representing production work orders and reject and downtime for each order...
6
by: GrandpaB | last post by:
While writing this plea for help, I think I solved my dilemma, but I don't know why the problem solving statement is necessary. The inspiration for the statement came from an undocumented VB...
6
by: Aaron Smith | last post by:
I have a form, oddly enough the same one with the expression column that is giving me a headache, and on this form I have a dataset that has a couple of tables in it that are related. If I do a...
2
by: guy | last post by:
if i use Generics.AddNew how do I pass an object to the items constructor? I have a set of class all inheriting from a base class, all requiring one parameter on their constructor - the data...
8
by: Andrew Bassett | last post by:
Hey everyone... I have what I hope is a simple question. I have a form with about a dozen controls bound to a databinding source. That datasource is bound to a dataset. Without using a binding...
0
by: hagar | last post by:
Hi all, I have a problem which I can not understand why this is happening! Debugging this I actually see that it grabs first record then when stepping through code to the line rsImportTo.AddNew...
5
by: amey.gupte | last post by:
Hi, I am using the AddNew function in VBA to populate my access table from data in excel. The following is the piece of code: With WriteRS .AddNew !column_Names(0) = "acctNo" !B = "CoName"...
3
by: Sheau Wei | last post by:
This is the search engine code that i create, but it was error and didnt come out the result. Cn u help me to check what wrong with my code? Thanks <Table cellspacing=1 cellPadding=1...
12
by: DFS | last post by:
I need to scan various network folders and capture all the filenames and create dates. ======================================================= 1st effort used the typical drive scan cFile =...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...

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.