请问:c#中sqlServer的连接问题

ducadi83 2004-05-04 12:22:55
这是教科书上的一个范例:
using System;
using System.Data;
using System.Data.SqlClient;

namespace DataSetRead
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Specify SQL Server-specific connection string
SqlConnection thisConnection = new SqlConnection(
@"Data Source=dougp\dogdata;uid=sa;password=datadog;" +
"Initial Catalog=northwind");

// Create DataAdapter object for update and other operations
SqlDataAdapter thisAdapter = new SqlDataAdapter(
"SELECT CustomerID, CompanyName FROM Customers", thisConnection);

// Create DataSet to contain related data tables, rows, and columns
DataSet thisDataSet = new DataSet();

// Fill DataSet using query defined previously for DataAdapter
thisAdapter.Fill(thisDataSet, "Customers");

foreach (DataRow theRow in thisDataSet.Tables["Customers"].Rows)
{
Console.WriteLine(theRow["CustomerID"] + "\t" +
theRow["CompanyName"]);
}


}
}
}
但是编译通过后,执行时会提示msvcr.dll/msvcp.dll找不到。
我明明在运行sqlserver,而且也检查了有northwind这个数据库。这是怎么回事啊?
...全文
65 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ducadi83 2004-05-05
  • 打赏
  • 举报
回复
已经解决了,谢谢大家:)
chenyuming2004 2004-05-04
  • 打赏
  • 举报
回复
看一下SQL SERVER服务器名有没有写错了,用户名和密码对不对了,
ducadi83 2004-05-04
  • 打赏
  • 举报
回复
谢谢,但是我应该怎么察看我的服务器名称,数据库的名称和密码呢?
alfredbogard 2004-05-04
  • 打赏
  • 举报
回复
是不是数据适配器的原因?

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧