Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 21st, 2006, 03:21 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default "Identifier expected" Error

I am trying to compile the following code but am getting an "Identifier expected" error on Line 1:

Private Sub btnExecute_Click(ByVal sender As System.Object,_
 ByVal e As System.EventArgs) Handles btnExecute.Click
    Dim cmd As SqlCommand = SqlConnection1.CreateCommand
    cmd.CommandType = CommandType.text
    cmd.CommandText = txtQuery.text
    Dim da As SqlDataAdapter = New SqlDataAdapter
    da.SelectCommand = cmd
    Dim ds As DataSet = New DataSet
    da.Fill(ds, "Results")
    dgResults.DataSource = ds
    dgResults.DataMember = "Results"
End Sub

Could anyone please advise why this might be?

Many thanks,

Neha
Reply With Quote
  #2 (permalink)  
Old January 22nd, 2006, 11:24 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Doesn't the compiler tell you where specifically the error is (in the line)? Also, which line is #1? The function declaration or the first line of the function?

-Peter
Reply With Quote
  #3 (permalink)  
Old January 22nd, 2006, 12:01 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The error is in the first line (at the end of the line)',_'

Many thanks.
Reply With Quote
  #4 (permalink)  
Old January 23rd, 2006, 01:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Take out the underscore ("_") in your first line.

J
Reply With Quote
  #5 (permalink)  
Old January 23rd, 2006, 11:41 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need a space between the , and _.

Private Sub btnExecute_Click(ByVal sender As System.Object, _

-Peter
Reply With Quote
  #6 (permalink)  
Old January 23rd, 2006, 06:44 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have removed the space and am still getting the same error.
Removing the underscore generates the same error aswell.

Reply With Quote
  #7 (permalink)  
Old January 23rd, 2006, 11:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

No, he said you need to add a space, not remove it. In his example:

Private Sub btnExecute_Click(ByVal sender As System.Object, _
 ByVal e As System.EventArgs) Handles btnExecute.Click
        Dim cmd As SqlCommand = SqlConnection1.CreateCommand
        cmd.CommandType = CommandType.Text
        cmd.CommandText = txtQuery.text
        Dim da As SqlDataAdapter = New SqlDataAdapter
        da.SelectCommand = cmd
        Dim ds As DataSet = New DataSet
        da.Fill(ds, "Results")
        dgResults.DataSource = ds
        dgResults.DataMember = "Results"
    End Sub



Or in mine, I forgot to add that if you take out the underscore, you need to have it all on the first line like this:

Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecute.Click
        Dim cmd As SqlCommand = SqlConnection1.CreateCommand
        cmd.CommandType = CommandType.Text
        cmd.CommandText = txtQuery.text
        Dim da As SqlDataAdapter = New SqlDataAdapter
        da.SelectCommand = cmd
        Dim ds As DataSet = New DataSet
        da.Fill(ds, "Results")
        dgResults.DataSource = ds
        dgResults.DataMember = "Results"
    End Sub

All of this:

Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecute.Click


is on a single line, not broken over two lines.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<identifier> expected error sprinkle Java Basics 1 February 11th, 2007 09:56 PM
"identifier> expected"error simmy_tj VB.NET 2002/2003 Basics 1 December 18th, 2006 08:31 AM
Identifier expected andriy JSP Basics 0 November 1st, 2006 11:28 PM
Identifier Expected syncmaster VB.NET 2002/2003 Basics 1 September 2nd, 2004 03:34 AM



All times are GMT -4. The time now is 09:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.