.NETGURU
I am trying to convert my VB script to C# here are the line that are the culprit
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngcs' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Dennis West
I am trying to convert my VB script to C# here are the line that are the culprit

// in VB the failing line was like this
// Dim parameterSearch As SqlParameter = New SqlParameter("@Search", SqlDbType.NVarChar, 255)

parameterSearch SqlParameter = New SqlParameter("@Search", SqlDbType.NVarChar, 255)
parameterSearch.Value = Request.Params("txtSearch");
myCommand.Parameters.Add(parameterPortalID);

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1002: ; expected

Source Error:

Line 41: // Dim parameterSearch As SqlParameter = New SqlParameter("@Search", SqlDbType.NVarChar, 255)
Line 42:
Line 43: parameterSearch SqlParameter = New SqlParameter("@Search", SqlDbType.NVarChar, 255)
Line 44: parameterSearch.Value = Request.Params("txtSearch");
Line 45: myCommand.Parameters.Add(parameterPortalID);

Source File: D:\Domains\aspalliance.com\dotnetsolutions\PortalCS\SearchModule\SearchAnnoucements.aspx Line: 43

private void Page_Load(object sender, System.EventArgs e) {

// Search database using the supplied "txtSearch" parameter

// Create Instance of Connection and Command Object

// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlCommand myCommand = new SqlCommand("AnnoucementSearch", myConnection);

// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;

// Add Parameters to SPROC

// in VB the failing line was like this
// Dim parameterSearch As SqlParameter = New SqlParameter("@Search", SqlDbType.NVarChar, 255)

parameterSearch SqlParameter = New SqlParameter("@Search", SqlDbType.NVarChar, 255)
parameterSearch.Value = Request.Params("txtSearch");
myCommand.Parameters.Add(parameterPortalID);

// Open the database connection and execute the command
myConnection.Open();
SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

// Bind the datareader

MyList.DataSource = dr;
MyList.DataBind();

// Display a message if no results are found
//If (MyList.Items.Count == 0) {
ErrorMsg.Text = "No items matched your query.";
//}

}

For 2002 ASP.NET Solutions & Articles goto:
http://aspalliance.com/dotnetsolutions/

Dennis West
West Design
MS .NET Developer
www. westontheweb.net
Click here to reveal e-mail address
Reply to this message...
 
    
Tim Musschoot
Well, it says ';' expected on line 43.

If you add a ';' at the end of line 43 the problem will be solved. In =
C# every line (closed statements!) ends with a semicolumn.

Best regards,
Tim Musschoot

----- Original Message -----
From: "Dennis West" <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Tue, 2 Jul 2002 00:38:19 -0700
Subject: I am trying to convert my VB script to C# here are the line =
that are the culprit
[Original message clipped]

=3Drror details and modify your source code appropriately.=20
[Original message clipped]

An=3Doucements.aspx Line: 43=20
[Original message clipped]

Reply to this message...
 
    
doug@accessmicrosystems.net (VIP)
In addition, C# is case sensitive, and I think the
"New" should be "new"

"Tim Musschoot" wrote

[Original message clipped]

ends with a semicolumn.
[Original message clipped]

request. Please review the following specific =rror
details and modify your source code appropriately.
[Original message clipped]

SqlDbType.NVarChar, 255)
[Original message clipped]


Douglas Reilly
Designing Microsoft(r) ASP.NET Applications
http://www.ProgrammingASP.net

Reply to this message...
 
 
System.Configuration.ConfigurationSettings
System.Data.CommandBehavior
System.Data.CommandType
System.Data.SqlClient.SqlCommand
System.Data.SqlClient.SqlConnection
System.Data.SqlClient.SqlDataReader
System.Data.SqlClient.SqlParameter
System.Data.SqlDbType
System.EventArgs




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification