R
Radu
I am trying to write a webmethod which would look a bit like this:
-------------------------------------------------------------------------------------------------------
private string ConnectionString
{
get { return
ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString; }
}
public string[] GetCompletionList_LN(String prefixText)
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand command = new
SqlCommand("sp_DTDS_GetEmployeesByLastName", conn);
SqlParameter param1 = new SqlParameter("@Name", SqlDbType.VarChar);
param1.Value = prefixText;
command.Parameters.Add(param1);
SqlParameter param1 = new SqlParameter("@Counter",
SqlDbType.VarChar);
param2.Size = 3;
param2.Direction = ParameterDirection.Output;
command.Parameters.Add(param2);
conn.Open();
SqlDataReader dtr;
dtr = command.ExecuteReader();
List<String> items = new List<String>();
try
{
while (dtr.Read())
{
items.Add(dtr(0).ToString);
}
}
finally
{
conn.Close();
}
Return items.ToArray();
}
}
-------------------------------------------------------------------------------------------------------
I had
SqlParameter param1 = New SqlParameter("@Name",
SqlDbType.VarChar);
instead of
SqlParameter param1 = new SqlParameter("@Name",
SqlDbType.VarChar);
with "New" instead of "new"
so the compiler complained about
; expected
(?????)
What was the keyword "New" supposed to be, in the compiler's mind ? A
tulip ? Of course New is new !!! I have lost three hours hunting this
down ! This, or course, triggered other stupid error messages
downstream, like, for instance,
conn.Close();
was saying
Invalid token '(' in class, struct, or interface member
declaration
Huh ?
Anyhoo. I still have one problem - the line
Return items.ToArray();
says
; expected
and also typing "items" + dot does not trigger any type of
autocomplete.
Is there smething wrong with
List<String> items = new List<String>();
???
Please, what am I doing wrong here ? This makes me pull my hair out,
and I don't have much left.
I am a VBnet programmer, and this case-sensitivity in C# is the most
stupid thing I've met.
Thank you
Alex.
-------------------------------------------------------------------------------------------------------
private string ConnectionString
{
get { return
ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString; }
}
public string[] GetCompletionList_LN(String prefixText)
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand command = new
SqlCommand("sp_DTDS_GetEmployeesByLastName", conn);
SqlParameter param1 = new SqlParameter("@Name", SqlDbType.VarChar);
param1.Value = prefixText;
command.Parameters.Add(param1);
SqlParameter param1 = new SqlParameter("@Counter",
SqlDbType.VarChar);
param2.Size = 3;
param2.Direction = ParameterDirection.Output;
command.Parameters.Add(param2);
conn.Open();
SqlDataReader dtr;
dtr = command.ExecuteReader();
List<String> items = new List<String>();
try
{
while (dtr.Read())
{
items.Add(dtr(0).ToString);
}
}
finally
{
conn.Close();
}
Return items.ToArray();
}
}
-------------------------------------------------------------------------------------------------------
I had
SqlParameter param1 = New SqlParameter("@Name",
SqlDbType.VarChar);
instead of
SqlParameter param1 = new SqlParameter("@Name",
SqlDbType.VarChar);
with "New" instead of "new"
so the compiler complained about
; expected
(?????)
What was the keyword "New" supposed to be, in the compiler's mind ? A
tulip ? Of course New is new !!! I have lost three hours hunting this
down ! This, or course, triggered other stupid error messages
downstream, like, for instance,
conn.Close();
was saying
Invalid token '(' in class, struct, or interface member
declaration
Huh ?
Anyhoo. I still have one problem - the line
Return items.ToArray();
says
; expected
and also typing "items" + dot does not trigger any type of
autocomplete.
Is there smething wrong with
List<String> items = new List<String>();
???
Please, what am I doing wrong here ? This makes me pull my hair out,
and I don't have much left.
I am a VBnet programmer, and this case-sensitivity in C# is the most
stupid thing I've met.
Thank you
Alex.