C# 将查询添加到Visual Studio 2013中的服务器资源管理器后发送到SQL Server
我正在使用visual Studio 2013 Professional和Microsoft SQL Server 2012。我在VisualStudio中找到了我的服务器,并创建了到它的数据连接,以便它显示在我的服务器资源管理器中(请参见下图)。但是,我找不到要添加到SQLConnection函数的服务器。我正在使用Visual C在Asp.net 4.5 Web应用程序中创建项目。在按钮2上单击“我得到”C# 将查询添加到Visual Studio 2013中的服务器资源管理器后发送到SQL Server,c#,sql,asp.net,sql-server,visual-studio-2013,C#,Sql,Asp.net,Sql Server,Visual Studio 2013,我正在使用visual Studio 2013 Professional和Microsoft SQL Server 2012。我在VisualStudio中找到了我的服务器,并创建了到它的数据连接,以便它显示在我的服务器资源管理器中(请参见下图)。但是,我找不到要添加到SQLConnection函数的服务器。我正在使用Visual C在Asp.net 4.5 Web应用程序中创建项目。在按钮2上单击“我得到” An exception of type 'System.ArgumentExcept
An exception of type 'System.ArgumentException' occurred in System.Data.dll
but was not handled in user code
Additional information: Format of the initialization string does not
conform to specification starting at index 0.`
代码
您需要提供数据库的完整连接字符串 e、 g
好的,谢谢,我无法让用户id正常工作,所以我将其作为受信任的\u连接打开,这样我就不需要用户名和密码,因为这只在我的机器上运行,所以不会产生安全问题。
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection vid = new SqlConnection("jason.Delta.dbo");
{
SqlCommand xp = new SqlCommand("Insert into account (UserName, Password,FirstName, LastName) Values(@user, @pass, @first, last)");
xp.Parameters.AddWithValue("@user", UserName);
"Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;"