使用控制台项目连接到DataBase时出错! [英] Error in Connection to DataBase with Console project!

查看:58
本文介绍了使用控制台项目连接到DataBase时出错!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用服务器和客户端,

在包含所有操作的服务器中(插入,更新,删除)

我试过这段代码,插入到表中,但是没有效果,甚至没有错误!!



I work with server and client,
In the server which contains All operations (Insert, update, Delete)
I tried this code, to insert into table, but there's no effect, or even error!!

InformationSystemDSTableAdapters.StudentTableAdapter StTA = new InformationSystemDSTableAdapters.StudentTableAdapter();
    StTA.InsertStudent(St.FirstName, St.LastName, St.BirthDate, St.Address, St.Gender);







我使用数据集

所以,

我决定提前使用数据库



我为App.Config添加了连接字符串




I worked with dataset
So,
I desided to work with data base ahead

I added connection string to App.Config

<add name="InformationSystemDBCS" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\InformationSystemDB.mdf;Integrated Security=True"
        providerName="System.Data.SqlClient" />





然后我用这段代码连接它:



Then I used this code to connect it:

string ConString = WebConfigurationManager.ConnectionStrings["InformationSystemDBCS"].ConnectionString;





但是会发生以下错误:



错误15无法将带有[]的索引应用于表达式类型'System.Configuration.ConnectionStringSettingsCollection'E:\SVU \MWS \ 04 ADP_F14_Mohmad Aljinidi \ ADPProject \ InformationSystem \ InformationSystem \RemoteInf ormationSystem \ MyInformationSystem.cs 38 32 RemoteInformationSystem

推荐答案

您好,



看起来你缺少对System.Configuration命名空间的引用吗?



尝试通过右键单击项目来添加System.Configuration命名空间参考项目 - >添加参考 - >找到.NET选项卡下的System.configuration并添加。



希望这会有所帮助。
Hi,

Looks are you missing reference to System.Configuration namespace ?

Try to add the System.Configuration namespace reference to your project, by right click on your project–>Add Reference–> find the System.configuration under the .NET tab and add.

Hope this helps.


这篇关于使用控制台项目连接到DataBase时出错!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆