C# 4.0 “无法打开数据库”;酒馆;由登录请求。登录失败。用户登录失败';ESLAM\ESLAM#u Nora';
您好,我正在尝试将总和信息存储在SQL Server表中,但当我运行表单并开始存储数据时,上面的运行时错误也会出现,SQL Server中的pubs数据库图标缺少(+)符号,这是怎么回事,我写了插入代码,提前谢谢C# 4.0 “无法打开数据库”;酒馆;由登录请求。登录失败。用户登录失败';ESLAM\ESLAM#u Nora';,c#-4.0,sql-server-2008-r2,windows-applications,C# 4.0,Sql Server 2008 R2,Windows Applications,您好,我正在尝试将总和信息存储在SQL Server表中,但当我运行表单并开始存储数据时,上面的运行时错误也会出现,SQL Server中的pubs数据库图标缺少(+)符号,这是怎么回事,我写了插入代码,提前谢谢 public partial class Add_Client : Form { SqlConnection clientConnection; string connString; SqlCommand insertCommand; public
public partial class Add_Client : Form
{
SqlConnection clientConnection;
string connString;
SqlCommand insertCommand;
public Add_Client()
{
InitializeComponent();
connString = "Data Source=.\\INSTANCE2;Initial Catalog=pubs; Integrated security=true ";
clientConnection = new SqlConnection();
clientConnection.ConnectionString = connString;
}
private void button1_ADD(object sender, EventArgs e)
{
try
{
SqlCommand insertCommand = new SqlCommand();
insertCommand.Connection = clientConnection;
insertCommand.CommandText = "INSERT INTO Client_Data values(@Client_Name,@Autorization_No,@Issue_Type,@Status)";
insertCommand.Parameters.Add("@Client_Name", SqlDbType.NVarChar, 60).Value = txt_Name.Text;
insertCommand.Parameters.Add("@Autorization_No", SqlDbType.Int, 60).Value = txt_Auth.Text.ToString();
insertCommand.Parameters.Add("@Issue_Type", SqlDbType.Text, 200).Value = txt_Iss.Text;
insertCommand.Parameters.Add("@Status", SqlDbType.Text, 200).Value = txt_Iss.Text;
//insertCommand.Parameters.Add("@Date To Memorize", SqlDbType.Date, 15).Value=Ca_Mem.se;
insertCommand.Connection.Open();
insertCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (clientConnection != null)
{
clientConnection.Close();
}
}
}
}
您可以使用集成安全性来访问数据库。因此,需要授权您的windows用户访问数据库。检查服务器和数据库的安全设置。如何检查设置,SQL server中的数据库图标缺少+符号!!如果您正在管理服务器,请使用SQL server Management Studio并使用授权帐户(通常是sa帐户)登录。如果您不是管理员,您必须与服务器管理员联系并向她寻求帮助。好的,我如何使用授权帐户(sa帐户)登录?
sa
是系统管理员帐户。在安装SQL Server时,会要求您输入该帐户的密码,因此我希望您手头有密码。然后像正常情况一样使用SSMS,并使用SQL server身份验证输入sa作为用户和密码。