读书人

不支持关键字database,该如何解决

发布时间: 2012-05-11 12:55:37 作者: rapoo

不支持关键字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
[解决办法]

探讨
SqlConnection thisConnection = new SqlConnection("Data Source=.;Integrated Security=SSPI;Database=Nothwind");
--------------- 试试 应该可以。
不行给我信息

[解决办法]
@lz:
您就是多加了一个双引号,所以才导致ADO.Net读取连接字符串时产生了异常!

读书人网 >C#

热点推荐