0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
namespace WcfService1
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
string Connection = "server=SHUMAILA-PC; database=kse; Connect Timeout=10000";
[WebMethod]
public void SQLconn()
{
SqlConnection DataConnection = new SqlConnection(Connection);
// the string with T-SQL statement, pay attention: no semicolon at the end of //the statement
string Command = "INSERT INTO login VALUES (shumaila,mypassword)";
// create the SQLCommand instance
SQLCommand DataCommand = new SqlCommand(Command, DataConnection);
// open the connection with our database
DataCommand.Connection.Open();
// execute the statement and return the number of affected rows
int i = DataCommand.ExecuteNonQuery();
//close the connection
DataCommand.Connection.Close();
}
}
}
我正在使用system.data.SqlClient指令,但它仍然給我這個錯誤。我該怎麼辦 ?SQLCommand(找不到類型或名稱,是否缺少任何指令)?
嗚是!謝謝 –
用戶登錄失敗。用戶未與可信的SQL Server連接相關聯。 –
這是我得到的第二個錯誤 –