User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 456,234 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,745 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 1077 | Replies: 2
Reply
Join Date: Nov 2007
Posts: 6
Reputation: haringmunti is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
haringmunti haringmunti is offline Offline
Newbie Poster

Help Need Help With Program

  #1  
Nov 13th, 2007
Hi Guys,

Im learning about ADO and Im learning it from a website. I followed all the directions and copy pasted the example. For button next, previous and last command button, it tells me there is an error.

the error say that an Identifier is expected in

Me.BindingContext(DataSet21, _ "table1"). Position + 1
Me.BindingContext(DataSet21,_ "table1"). Position - 1
Me.BindingContext(DataSet21,_ "table1"). Count - 1



That small underline there is where the error is. when i remove it and run the program the computer tells me there is a problem. can someone tell me what i should do. so with or without it, im screwed. Is there something I forgot to do? Like I said, I copy pasted the program from the website and did everything step by step so why does this still happen?

Need help badly. Attached below is the code.


<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.txtID = New System.Windows.Forms.TextBox
Me.EMPBindingSource = New System.Windows.Forms.BindingSource(Me.components)
Me.DataSet21 = New WindowsApplication1.DataSet2
Me.TXTNAME = New System.Windows.Forms.TextBox
Me.TXTLOCATION = New System.Windows.Forms.TextBox
Me.TXTSALARY = New System.Windows.Forms.TextBox
Me.TXTDESIGNATION = New System.Windows.Forms.TextBox
Me.btnfirst = New System.Windows.Forms.Button
Me.btnnext = New System.Windows.Forms.Button
Me.btnprevious = New System.Windows.Forms.Button
Me.btnlast = New System.Windows.Forms.Button
Me.btnload = New System.Windows.Forms.Button
Me.btnupdate = New System.Windows.Forms.Button
Me.btninsert = New System.Windows.Forms.Button
Me.btnClear = New System.Windows.Forms.Button
Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
Me.OleDbDataAdapter1 = New System.Data.OleDb.OleDbDataAdapter
CType(Me.EMPBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataSet21, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(24, 45)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(39, 13)
Me.Label1.TabIndex = 0
Me.Label1.Text = "EmpID"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(24, 80)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 13)
Me.Label2.TabIndex = 1
Me.Label2.Text = "EmpName"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(24, 118)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(69, 13)
Me.Label3.TabIndex = 2
Me.Label3.Text = "EmpLocation"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(24, 155)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(57, 13)
Me.Label4.TabIndex = 3
Me.Label4.Text = "EmpSalary"
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(24, 190)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(84, 13)
Me.Label5.TabIndex = 4
Me.Label5.Text = "EmpDesignation"
'
'txtID
'
Me.txtID.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EMPBindingSource, "EmpID", True, System.Windows.Forms.DataSourceUpdateMode.OnValidation, Nothing, "N0"))
Me.txtID.Location = New System.Drawing.Point(127, 42)
Me.txtID.Name = "txtID"
Me.txtID.Size = New System.Drawing.Size(100, 20)
Me.txtID.TabIndex = 5
'
'EMPBindingSource
'
Me.EMPBindingSource.DataMember = "EMP"
Me.EMPBindingSource.DataSource = Me.DataSet21
'
'DataSet21
'
Me.DataSet21.DataSetName = "DataSet2"
Me.DataSet21.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
'
'TXTNAME
'
Me.TXTNAME.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EMPBindingSource, "EmpName", True))
Me.TXTNAME.Location = New System.Drawing.Point(127, 80)
Me.TXTNAME.Name = "TXTNAME"
Me.TXTNAME.Size = New System.Drawing.Size(100, 20)
Me.TXTNAME.TabIndex = 6
'
'TXTLOCATION
'
Me.TXTLOCATION.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EMPBindingSource, "Emplocation", True))
Me.TXTLOCATION.Location = New System.Drawing.Point(127, 118)
Me.TXTLOCATION.Name = "TXTLOCATION"
Me.TXTLOCATION.Size = New System.Drawing.Size(100, 20)
Me.TXTLOCATION.TabIndex = 7
'
'TXTSALARY
'
Me.TXTSALARY.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EMPBindingSource, "EmpSalary", True, System.Windows.Forms.DataSourceUpdateMode.OnValidation, Nothing, "N0"))
Me.TXTSALARY.Location = New System.Drawing.Point(127, 152)
Me.TXTSALARY.Name = "TXTSALARY"
Me.TXTSALARY.Size = New System.Drawing.Size(100, 20)
Me.TXTSALARY.TabIndex = 8
'
'TXTDESIGNATION
'
Me.TXTDESIGNATION.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.EMPBindingSource, "EmpDesignation", True))
Me.TXTDESIGNATION.Location = New System.Drawing.Point(127, 190)
Me.TXTDESIGNATION.Name = "TXTDESIGNATION"
Me.TXTDESIGNATION.Size = New System.Drawing.Size(100, 20)
Me.TXTDESIGNATION.TabIndex = 9
'
'btnfirst
'
Me.btnfirst.Location = New System.Drawing.Point(40, 260)
Me.btnfirst.Name = "btnfirst"
Me.btnfirst.Size = New System.Drawing.Size(77, 30)
Me.btnfirst.TabIndex = 10
Me.btnfirst.Text = "<<First"
Me.btnfirst.UseVisualStyleBackColor = True
'
'btnnext
'
Me.btnnext.Location = New System.Drawing.Point(150, 260)
Me.btnnext.Name = "btnnext"
Me.btnnext.Size = New System.Drawing.Size(77, 30)
Me.btnnext.TabIndex = 11
Me.btnnext.Text = "Next>"
Me.btnnext.UseVisualStyleBackColor = True
'
'btnprevious
'
Me.btnprevious.Location = New System.Drawing.Point(251, 260)
Me.btnprevious.Name = "btnprevious"
Me.btnprevious.Size = New System.Drawing.Size(77, 30)
Me.btnprevious.TabIndex = 12
Me.btnprevious.Text = "<Previous"
Me.btnprevious.UseVisualStyleBackColor = True
'
'btnlast
'
Me.btnlast.Location = New System.Drawing.Point(349, 260)
Me.btnlast.Name = "btnlast"
Me.btnlast.Size = New System.Drawing.Size(77, 30)
Me.btnlast.TabIndex = 13
Me.btnlast.Text = "Last>>"
Me.btnlast.UseVisualStyleBackColor = True
'
'btnload
'
Me.btnload.Location = New System.Drawing.Point(428, 45)
Me.btnload.Name = "btnload"
Me.btnload.Size = New System.Drawing.Size(77, 30)
Me.btnload.TabIndex = 14
Me.btnload.Text = "Load"
Me.btnload.UseVisualStyleBackColor = True
'
'btnupdate
'
Me.btnupdate.Location = New System.Drawing.Point(428, 90)
Me.btnupdate.Name = "btnupdate"
Me.btnupdate.Size = New System.Drawing.Size(77, 30)
Me.btnupdate.TabIndex = 15
Me.btnupdate.Text = "Update"
Me.btnupdate.UseVisualStyleBackColor = True
'
'btninsert
'
Me.btninsert.Location = New System.Drawing.Point(428, 138)
Me.btninsert.Name = "btninsert"
Me.btninsert.Size = New System.Drawing.Size(77, 30)
Me.btninsert.TabIndex = 16
Me.btninsert.Text = "Insert"
Me.btninsert.UseVisualStyleBackColor = True
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(428, 184)
Me.btnClear.Name = "btnClear"
Me.btnClear.Size = New System.Drawing.Size(77, 30)
Me.btnClear.TabIndex = 17
Me.btnClear.Text = "Clear"
Me.btnClear.UseVisualStyleBackColor = True
'
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT EMP.*" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "FROM EMP"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'OleDbConnection1
'
Me.OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\EMP.MDB"
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO `EMP` (`EmpID`, `EmpName`, `Emplocation`, `EmpSalary`, `EmpDesignatio" & _
"n`) VALUES (?, ?, ?, ?, ?)"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.AddRange(New System.Data.OleDb.OleDbParameter() {New System.Data.OleDb.OleDbParameter("EmpID", System.Data.OleDb.OleDbType.[Double], 0, "EmpID"), New System.Data.OleDb.OleDbParameter("EmpName", System.Data.OleDb.OleDbType.VarWChar, 0, "EmpName"), New System.Data.OleDb.OleDbParameter("Emplocation", System.Data.OleDb.OleDbType.VarWChar, 0, "Emplocation"), New System.Data.OleDb.OleDbParameter("EmpSalary", System.Data.OleDb.OleDbType.VarWChar, 0, "EmpSalary"), New System.Data.OleDb.OleDbParameter("EmpDesignation", System.Data.OleDb.OleDbType.VarWChar, 0, "EmpDesignation")})
'
'OleDbDataAdapter1
'
Me.OleDbDataAdapter1.InsertCommand = Me.OleDbInsertCommand1
Me.OleDbDataAdapter1.SelectCommand = Me.OleDbSelectCommand1
Me.OleDbDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "EMP", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("EmpID", "EmpID"), New System.Data.Common.DataColumnMapping("EmpName", "EmpName"), New System.Data.Common.DataColumnMapping("Emplocation", "Emplocation"), New System.Data.Common.DataColumnMapping("EmpSalary", "EmpSalary"), New System.Data.Common.DataColumnMapping("EmpDesignation", "EmpDesignation")})})
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(542, 329)
Me.Controls.Add(Me.btnClear)
Me.Controls.Add(Me.btninsert)
Me.Controls.Add(Me.btnupdate)
Me.Controls.Add(Me.btnload)
Me.Controls.Add(Me.btnlast)
Me.Controls.Add(Me.btnprevious)
Me.Controls.Add(Me.btnnext)
Me.Controls.Add(Me.btnfirst)
Me.Controls.Add(Me.TXTDESIGNATION)
Me.Controls.Add(Me.TXTSALARY)
Me.Controls.Add(Me.TXTLOCATION)
Me.Controls.Add(Me.TXTNAME)
Me.Controls.Add(Me.txtID)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.EMPBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataSet21, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()

End Sub
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents txtID As System.Windows.Forms.TextBox
Friend WithEvents TXTNAME As System.Windows.Forms.TextBox
Friend WithEvents TXTLOCATION As System.Windows.Forms.TextBox
Friend WithEvents TXTSALARY As System.Windows.Forms.TextBox
Friend WithEvents TXTDESIGNATION As System.Windows.Forms.TextBox
Friend WithEvents btnfirst As System.Windows.Forms.Button
Friend WithEvents btnnext As System.Windows.Forms.Button
Friend WithEvents btnprevious As System.Windows.Forms.Button
Friend WithEvents btnlast As System.Windows.Forms.Button
Friend WithEvents btnload As System.Windows.Forms.Button
Friend WithEvents btnupdate As System.Windows.Forms.Button
Friend WithEvents btninsert As System.Windows.Forms.Button
Friend WithEvents btnClear As System.Windows.Forms.Button
Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
Friend WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter
Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
Friend WithEvents DataSet21 As WindowsApplication1.DataSet2
Friend WithEvents EMPBindingSource As System.Windows.Forms.BindingSource

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'data binding demo
End Sub

Private Sub btnload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnload.Click
OleDbDataAdapter1.Fill(DataSet21)
'filling the dataset and loading records into the textboxes
End Sub

Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click
Try
Me.BindingContext(DataSet21, "table1").EndCurrentEdit()
Me.OleDbDataAdapter1.Update(DataSet21)
'ending current editing and updating the dataset
Catch
End Try
End Sub

Private Sub btninsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btninsert.Click
Me.BindingContext(DataSet21, "table1").AddNew()
'adding new record/row to the table
MsgBox("Successfully Inserted")
End Sub

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtID.Text = " "
TXTNAME.Text = " "
TXTLOCATION.Text = " "
TXTSALARY.Text = " "
TXTDESIGNATION.Text = " "
'setting all textboxes to null
End Sub

Private Sub btnfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfirst.Click
Me.BindingContext(DataSet21, "table1").Position = 0
'using forms's BindingContext property's position member and setting it to 0
'displays the first row from table
End Sub

Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click
Me.BindingContext(DataSet21, "table1").Position = Me.BindingContext(DataSet21,_ "table1"). Position + 1
'incrementing the position property of the binding context
End Sub

Private Sub btnprevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprevious.Click
Me.BindingContext(DataSet21, "table1").Position = Me.BindingContext(DataSet21,_ "table1"). Position - 1
End Sub

Private Sub btnlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlast.Click
Me.BindingContext(DataSet21, "table1").Position = Me.BindingContext(DataSet21,_ "table1"). Count - 1
'the count property returns the total number of records in the table
End Sub
End Class
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: � Jogja �
Posts: 2,590
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Rep Power: 11
Solved Threads: 236
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Need Help With Program

  #2  
Nov 26th, 2007
this is you the part example code :
Me.BindingContext(DataSet21, "table1").Position = Me.BindingContext(DataSet21,_ "table1"). Count - 1

you make mistake on your code.
delete a underscore sign (_) in (DataSet21,_ "table1").
do same changes to similar code..
Last edited by Jx_Man : Nov 26th, 2007 at 3:28 am.
Reply With Quote  
Join Date: Nov 2007
Posts: 6
Reputation: haringmunti is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
haringmunti haringmunti is offline Offline
Newbie Poster

Help Re: Need Help With Program

  #3  
Nov 26th, 2007
hi,
i did that and the program appears without errors. However, when I run it after removing the underscore sign, another error appears. it tells me

"childlist for table field 1 cannot be created. argument exception was unhandled."

is there another way of doing it that will allow me to run the program without errors and at the same time save data from vb to access?

pls let me know. if possible, pls write the code so I can try to run it from here.

Thanks.
Last edited by haringmunti : Nov 26th, 2007 at 9:51 pm. Reason: wrong spelling
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 5:08 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC