Click here to Skip to main content
15,903,362 members

Comments by SarthakGowda (Top 2 by date)

SarthakGowda 17-Oct-13 3:20am View    
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> get_vehicleno(string prefixText)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BMS"].ToString());
con.Open();
SqlCommand cmd15 = new SqlCommand("select * from tbl_vehicle where vehicle_registration_no like @Name+'%'", con);
cmd15.Parameters.AddWithValue("@Name", txt_vech_no.Text.Trim());
SqlDataAdapter da15 = new SqlDataAdapter(cmd15);
DataTable dt15 = new DataTable();
da15.Fill(dt15);
List<string> CountryNames12 = new List<string>();
for (int i = 0; i < dt15.Rows.Count; i++)
{
CountryNames12.Add(dt15.Rows[i][1].ToString());
}
return CountryNames12;
}
SarthakGowda 17-Oct-13 3:20am View    
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> get_vehicleno(string prefixText)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BMS"].ToString());
con.Open();
SqlCommand cmd15 = new SqlCommand("select * from tbl_vehicle where vehicle_registration_no like @Name+'%'", con);
cmd15.Parameters.AddWithValue("@Name", txt_vech_no.Text.Trim());
SqlDataAdapter da15 = new SqlDataAdapter(cmd15);
DataTable dt15 = new DataTable();
da15.Fill(dt15);
List<string> CountryNames12 = new List<string>();
for (int i = 0; i < dt15.Rows.Count; i++)
{
CountryNames12.Add(dt15.Rows[i][1].ToString());
}
return CountryNames12;
}


It is throwing an error as "AN OBJECT REFERENCE IS REQUIRED FOR THE NON STATIC FIELD" near the code u sujjested.. cmd15.Parameters.AddWithValue("@Name", txt_vech_no.Text.Trim() );