473,507 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

declaration expected

1 New Member
below testing code gives an error "declaration expected"
please suggest

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.SqlClient
  2.  
  3. Public Class Form1
  4.     Inherits System.Windows.Forms.Form
  5.     'Create ADO.NET objects.
  6.     Private myConn As SqlConnection
  7.     Private myCmd As SqlCommand
  8.     Private myReader As SqlDataReader
  9.     Private results As String
  10.     'Create a Connection object.
  11. 'here i got error on myConn that is declaration expected
  12.         myConn = New SqlConnection("Initial Catalog=Northwind;" & _
  13.                 "Data Source=localhost;Integrated Security=SSPI;")
  14.  
  15.     'Create a Command object.
  16.        myCmd = myConn.CreateCommand
  17.         myCmd.CommandText = "SELECT FirstName, LastName FROM Employees"
  18.  
  19.     'Open the connection.
  20.         myConn.Open()
  21.  
  22.  
  23.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  24.         myReader = myCmd.ExecuteReader()
  25.         'Concatenate the query result into a string.
  26.         Do While myReader.Read()
  27.             results = results & myReader.GetString(0) & vbTab & _
  28.      myReader.GetString(1) & vbLf
  29.         Loop
  30.         'Display results.
  31.         MsgBox(results)
  32.         'Close the reader and the database connection.
  33.         myReader.Close()
  34.         myConn.Close()
  35.  
  36.     End Sub
  37. End Class
  38.  
Sep 27 '09 #1
1 2638
Plater
7,872 Recognized Expert Expert
Hmm, the code itself doesn't seem wrong, assuming that connection string is valid.
Sep 28 '09 #2

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

Similar topics

83
6422
by: Alexander Zatvornitskiy | last post by:
Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in...
1
16339
by: Ammar_ace | last post by:
Can Somebbody pls help me out here. i am new to .net programming, i am trying to connect to an access database and read, but i get the error message 'BC30188 Declaration Expected' this is what i...
9
5018
by: D. Shane Fowlkes | last post by:
Still learning ASP.NET....(and I was getting so good with classic ASP too!). I'm trying to connect to a SQL Server using a simple connection script. I've checked 2 different books and looked at...
2
5307
by: Simon Harris | last post by:
Hi All, I have a page which I want to accept an ID on the querystring - I'm trying to get this ID into a hidden form field. I have the following code at the top of my page: Line 5: <script...
3
50437
by: gamehack | last post by:
Hi all, Here's the error which I'm getting when trying to compile some code: boxmanager.h:16: error: ISO C++ forbids declaration of 'vector' with no type boxmanager.h:16: error: expected...
1
1890
by: INeedADip | last post by:
What is the difference between: function setupGrid( param ){......} and setupGrid = function( param ){......} Are there any advantages to doing one over the other?
7
9422
by: Florian Haag | last post by:
Hello, I'm trying to compile a programme which compiles fine under Linux; I'm trying it with MinGW G++ 3.4.2: Component.h: #ifndef COMPONENT_H_ #define COMPONENT_H_
8
7851
by: aneuryzma | last post by:
Hello, I'm merging an OpenCV app with an Ogre3d app. I'm on a mac, I'm using xCode. When I add #include "openCVApp.h" I got the following error:
6
14707
by: samsneelam | last post by:
Hi.. This is samuel, while doing a program, i encountered this problem.. Let me give you clarity regarding my prob.. I am having two files .. one is mpcplib.h it contains the follwing...
0
7223
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
7111
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...
0
7319
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,...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4702
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...
0
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
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 ...
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.