下面的代码是 web 方法(这是最常见的方法,你可以在任何地方看到它),但我不断从标题中得到错误。我刚开始使用 .NET,所以如果有人能指出我正确的方向,请这样做。
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["mySQLconn"].ConnectionString);
[WebMethod(Description = "Select Customers")]
public string GetVersionofSelectedCustomer(string versionEmail)
{
string select = "SELECT version FROM customer WHERE EMAIL = '" + versionEmail + "'";
SqlDataAdapter adapter = new SqlDataAdapter(select, myConnection);
DataSet custDS = new DataSet();
//adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
adapter.Fill(custDS, "Customers");
return custDS;
}
连接在 Web.config 中定义(本地连接)并返回 custDS;是失败的地方。