Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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!!

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



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

I added connection string to App.Config
HTML
<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:
C#
string ConString = WebConfigurationManager.ConnectionStrings["InformationSystemDBCS"].ConnectionString;


But this error occur :

Error 15 Cannot apply indexing with [] to an expression of type 'System.Configuration.ConnectionStringSettingsCollection' E:\SVU\MWS\04 ADP_F14_Mohmad Aljinidi\ADPProject\InformationSystem\InformationSystem\RemoteInformationSystem\MyInformationSystem.cs 38 32 RemoteInformationSystem
Posted
Comments
[no name] 7-Jul-15 10:55am    
First you need to slow down and think about what you are doing.
What does ASP.NET have to do with your problem? Nothing.
Why would you be using WebConfigurationManager for a console app?
http://www.codeproject.com/Tips/416198/How-to-get-Connection-String-from-App-Config-in-cs
Y.Ahmad 7-Jul-15 11:31am    
I tried what is wrote,
And I added the usings,
But an error occor on ConfigurationManager
Doesn't exist in the current text!
virusstorm 7-Jul-15 11:54am    
Make sure you reply to the person's comment so they know there is a response waiting.

Did you try exactly what is in the article that Wes Aday provided?
Y.Ahmad 7-Jul-15 14:09pm    
I don't have a lot of time, and I did what Wes Aday provided.. As I wrote in my last replay..

1 solution

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.
 
Share this answer
 
Comments
Y.Ahmad 10-Jul-15 19:34pm    
Sorry, I didn't do feedback,
I add the Reference in last that day, but no thing stored in the database,
Every thing stored in temporary Database I find it in this folder: Bin\Debug..
And in the next insert, all past data removed..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900