问题描述
错误信息如下:Erroraccessingthedatabase:传递给数据库'Northwind'中的日志扫描操作的日志扫描号(39:282:2)无效。此错误可能指示数据损坏,或者日志文件(.ldf)与数据文件(.mdf)不匹配。如果此错误是在复制期间出现的,请重新创建发布。否则,如果该问题导致启动期间出错,请从备份还原。警告:在111020071:36AM出现错误3414。请记录该错误和时间,并与您的系统管理员联系。无法打开登录所请求的数据库"Northwind"。登录失败。用户'Abdiel-PCAbdiel'登录失败。难道是传说中的没用管理员身份运行导致的?可是我到Debug文件夹下用管理员身份运行了这个程序,结果是一样的SQLExpress登录身份为内置帐户localsystemSqlConnectiondataConnection=newSqlConnection();try{dataConnection.ConnectionString="IntegratedSecurity=true;"+"InitialCatalog=Northwind;"+"DataSource=Abdiel-PC\SQLExpress";dataConnection.Open();Console.WriteLine("PleaseenteracustomerID(5characters):");stringcustomerID=Console.ReadLine();SqlCommanddataCommand=newSqlCommand();dataCommand.Connection=dataConnection;dataCommand.CommandText="SELECTOrderID,OrderDate,"+"ShippedDate,ShipName,ShipAddress,ShipCity,"+"ShipCountry";dataCommand.CommandText+="FROMOrdersWHERECustomerID'"+customerID+"'";Console.WriteLine("Abouttoexcute:{0}nn",dataCommand.CommandText);SqlDataReaderdataReader=dataCommand.ExecuteReader();while(dataReader.Read()){intorderID=dataReader.GetInt32(0);DateTimeorderDate=dataReader.GetDateTime(1);DateTimeshipDate=dataReader.GetDateTime(2);stringshipName=dataReader.GetString(3);stringshipAddress=dataReader.GetString(4);stringshipCity=dataReader.GetString(5);stringshipCountry=dataReader.GetString(6);Console.WriteLine("Order{0}nPlaced{1}nShipped{2}n"+"ToAddress{3}n{4}n{5}n{6}nn",orderID,orderDate,shipDate,shipName,shipAddress,shipCity,shipCountry);}dataReader.Close();}catch(Exceptione){Console.WriteLine("Erroraccessingthedatabase:"+e.Message);}finally{dataConnection.Close();}
解决方案
解决方案二:
我在XP下是没有问题的Vista怎么这样。。。。。还不如装回XP网上说开发C#最好用2003,是吗?