473,666 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

declaration expected

1 New Member
below testing code gives an error "declaratio n 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 2644
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
6481
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 C. It can cause very ugly errors,like this: epsilon=0 S=0 while epsilon<10: S=S+epsilon
1
16348
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 did 'create the connection object Dim objConn As New System.Data.OLEDB.Connection() .. .. ..
9
5025
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 www.asp.net and still cannot get past this "error". Can anyone see the error? This <script> example is almost line by line from the Sams ASP.NET Unleashed Book. The error is on line 8. Thanks.
2
5314
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 language="VB" runat="server"> Line 6: dim ResortID as integer Line 7: ResortID = Request.QueryString("resortid")
3
50482
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 ';' before '<' token boxmanager.h:17: error: ISO C++ forbids declaration of 'vector' with no type
1
1901
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
9423
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
7864
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
14719
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 declerations.... #include <queue> #include <vector> #include <string> class database { queue<delayTP> delayThrouput;
0
8440
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7378
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...
1
6189
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4192
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
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
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
2005
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.