I've decided to convert one of my VB.Net pages to C#. I used a C# converter at
http://www.developerfusion.com/utilities/convertvbtocsharp.a spx. It has been helpful. But it is not 100% accurate.
I need help with the following lines of code:
1.)
VB.Net: Private Function ConnectionString () as String
Dim servername, username, password, databasename As String
servername = ""
username = ""
password = ""
databasename = ""
Dim conString As String
conString = conString.Format("server={0};User ID={1};Password={2};Database={3};", servername, username, password, databasename)
Return conString
End Function
C#: private string ConnectionString()
{
string servername;
string username;
string password;
string databasename;
servername = "";
username = "";
password = "";
databasename = "";
string conString;
conString = conString.Format("server={0};User ID={1};Password={2};Database={3};", servername, username, password, databasename);
return conString;
}
I got the following error message regarding the bolded code in C#: Compiler Error Message: CS0246: The type or namespace name 'conString' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
|
Line 28: databasename = "spastoredirectory";
Line 29: string conString;
Line 30: conString = conString.Format("server={0};User ID={1};Password={2};Database={3};", servername, username, password, databasename);
Line 31: return conString;
Line 32: } |
2.)
VB.Net: strChosenState = request.params("State") (worked fine in VB.Net)
C#: strChosenState = request.params("State");
I got the following error message in C#:
Compiler Error Message: CS1041: Identifier expected, 'params' is a keyword
Source Error:
|
Line 38:
Line 39: //Get incoming querystring values
Line 40: strChosenState = request.params("State");
|