不支持关键字database
#region Using Directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
#endregion
namespace datass
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection thisConnection = new SqlConnection(@"server=local;Integrated Security=True;""Database=Nothwind");
thisConnection.Open();
SqlCommand thiscommand = thisConnection.CreateCommand();
thiscommand.CommandText = "SELECT 学号 姓名 from StuInf";
SqlDataReader thisReader = thiscommand.ExecuteReader();
string ms;
while (thisReader.Read())
{
}
thisReader.Close();
thisConnection.Close();
}
}
运行后提示不支持关键字database,哪位请指教一下,感激不尽!
[解决办法]
是不是連接字符寫錯了啊.,錯誤在哪句?
[解决办法]
SqlConnection thisConnection = new SqlConnection(@"server=local;Integrated Security=True;Data Source=Nothwind");
[解决办法]
SqlConnection thisConnection = new SqlConnection(@"server=local;Integrated Security=True;""Database=Nothwind");
改成
SqlConnection thisConnection = new SqlConnection(@"server=local;Integrated Security=True;""Data Source=Nothwind");
[解决办法]
SqlConnection thisConnection = new SqlConnection("Data Source=.;Integrated Security=SSPI;Database=Nothwind");
--------------- 试试 应该可以。
不行给我信息
[解决办法]
SqlConnection thisConnection = new SqlConnection("Data Source=你的计算机名;Integrated Security=SSPI;Initial Catalog=Nothwind");
改成这样试试
[解决办法]
SqlConnection thisConnection = new SqlConnection("Data Source=你的计算机名;InIntegrated Security=True;Initial Catalog=Nothwind");
我用的是这种类型的,可以。。。
[解决办法]
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Data Source=(local);Initial Catalog=TEST;User ID=sa;Password=sa
[解决办法]