.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 'aspngdata' list.


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...
 
    
James Avery
There is no ; at the end of Line 43. Add one and it should work.

-----Original Message-----
From: Dennis West [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 02, 2002 3:38 AM
To: aspngdata
Subject: [aspngdata] I am trying to convert my VB script to C# here are
the line that are the culprit

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\SearchA
nnoucements.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

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
    
James Avery
And your declaration is backwards... sorry for not catching it the first
time. Should be like this:

SqlParameter parameterSearch = new SqlParameter("@search",
SqlDbType.NVarChar, 244);

new should always be lower case.

This can also be combined into one line like this:

myCommand.Parameters.Add("@Search", SqlDbType.NVarChar, 255).Value Request.Params("textsearch");

-----Original Message-----
From: Dennis West [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 02, 2002 3:38 AM
To: aspngdata
Subject: [aspngdata] I am trying to convert my VB script to C# here are
the line that are the culprit

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\SearchA
nnoucements.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

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
    
Minh Truong
[Original message clipped]

You're missing the pesky ";" at the end of this line.

Reply to this message...
 
    
Dennis West
Messageavery. thanks it was the New to new that did it. but now I get this any hints the request was working in VB

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: CS0118: 'System.Web.HttpRequest.Params' denotes a 'property' where a 'method' was expected

Source Error:

Line 37:
Line 38: // Add Parameters to SPROC
Line 39: myCommand.Parameters.Add("@Search", SqlDbType.NVarChar, 255).Value = Request.Params("textsearch");
Line 40: //SqlParameter parameterSearch = new SqlParameter("@Search", SqlDbType.NVarChar, 255);
Line 41: //parameterSearch.Value = Request.Params("txtSearch");

Source File: D:\Domains\aspalliance.com\dotnetsolutions\PortalCS\SearchModule\SearchAnnoucements.aspx Line: 39
----- Original Message -----
From: James Avery
To: aspngdata
Sent: Tuesday, July 02, 2002 6:41 AM
Subject: [aspngdata] RE: I am trying to convert my VB script to C# here are the line that are the culprit

And your declaration is backwards... sorry for not catching it the first time. Should be like this:

SqlParameter parameterSearch = new SqlParameter("@search", SqlDbType.NVarChar, 244);

new should always be lower case.

This can also be combined into one line like this:

myCommand.Parameters.Add("@Search", SqlDbType.NVarChar, 255).Value = Request.Params("textsearch");
-----Original Message-----
From: Dennis West [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 02, 2002 3:38 AM
To: aspngdata
Subject: [aspngdata] I am trying to convert my VB script to C# here are the line that are the culprit

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

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
    
James Avery
Oh yeah. :) In C# use [ ] when something is a property, () for methods.

so it should be Request.Params["textsearch"];

-----Original Message-----
From: Dennis West [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 02, 2002 12:06 PM
To: aspngdata
Subject: [aspngdata] RE: I am trying to convert my VB script to C# here
are the line that are the culprit

avery. thanks it was the New to new that did it. but now I get this any
hints the request was working in VB

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: CS0118: 'System.Web.HttpRequest.Params' denotes
a 'property' where a 'method' was expected

Source Error:

    

Line 37:

Line 38: // Add Parameters to SPROC

Line 39: myCommand.Parameters.Add("@Search",
SqlDbType.NVarChar, 255).Value = Request.Params("textsearch");

Line 40: //SqlParameter parameterSearch = new
SqlParameter("@Search", SqlDbType.NVarChar, 255);

Line 41: //parameterSearch.Value Request.Params("txtSearch");

Source File:
D:\Domains\aspalliance.com\dotnetsolutions\PortalCS\SearchModule\SearchA
nnoucements.aspx Line: 39

----- Original Message -----
From: James <mailto:Click here to reveal e-mail address> Avery
To: aspngdata <mailto:Click here to reveal e-mail address>
Sent: Tuesday, July 02, 2002 6:41 AM
Subject: [aspngdata] RE: I am trying to convert my VB script to C# here
are the line that are the culprit

And your declaration is backwards... sorry for not catching it the first
time. Should be like this:

SqlParameter parameterSearch = new SqlParameter("@search",
SqlDbType.NVarChar, 244);

new should always be lower case.

This can also be combined into one line like this:

myCommand.Parameters.Add("@Search", SqlDbType.NVarChar, 255).Value Request.Params("textsearch");

-----Original Message-----
From: Dennis West [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 02, 2002 3:38 AM
To: aspngdata
Subject: [aspngdata] I am trying to convert my VB script to C# here are
the line that are the culprit

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\SearchA
nnoucements.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

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
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
System.Web.HttpRequest




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