请亲爱的,这是我的代码,一切都很好,但GlobalVar没有被宣布任何建议。
[WebMethod(MessageName = "OpenAccount", Description = "This method is to add new account")]
[System.Xml.Serialization.XmlInclude(typeof(ContactResult))]
public ContactResult openaccount(String FullName, String Phone)
{
ContactResult cr = new ContactResult();
**GlobalVar var = new GlobalVar();**
try
{
using (SqlConnection openconn = new SqlConnection(var.connectionstring))
{
string save = "INSERT into AndroidContact (AndroidContactName,AndroidContactPhone) VALUES ('" + FullName + "' ,'" + Phone + "')";
using (SqlCommand query = new SqlCommand(save))
{
query.Connection = openconn;
query.Parameters.Add("@AndroidContactName", SqlDbType.NVarChar, 50).Value = FullName;
query.Parameters.Add("@AndroidContactPhone", SqlDbType.NVarChar, 50).Value = Phone;
openconn.Open();
query.ExecuteNonQuery();
openconn.Close();
}
}
cr.ErrorID = 0;
cr.ErrorMessage = "Contact Added";
return cr;
}
catch (Exception ex){
cr.ErrorID = 1;
cr.ErrorMessage = ex.Message;
return cr;
}
}
}
}
1条答案
按热度按时间mwg9r5ms1#
谢谢,但我的是这样的: