简体   繁体   中英

C# - Sql Server very simple connection

I am trying to connect my Sql Server database to a C# application. I want to do this without writing code, using the design part from C#.

So, I created a new Windows From application, I connected my From with my Sql Server database (setting this from DataBindings -> Text), I went to Data Sources and just drag-and-drop one table, then drag-and-drop a Binding Navigator which I bounded to my corresponding table. You can see below the result.

It takes my data from the Sql Database, but when I run it and perform a change, for example deleting a record, this change is not saved in my database. How can I make it work?

在此处输入图片说明

Firstly, you need to be prepared to write some code to perform the actions you're after.

Personally, I think you'd be better off creating your connection strings in your app.config file, creating your connection in a connection class and using a bit of script to insert, update and delete data in your database tables.

If you require some assistance doing it this way I'd be happy to help :)

I just don't believe wizards are the correct approach to these types of scenarios because projects usually get more involved after this point, in which case coding is essential.

looking in project / properties under settings, whether the connecting string of path to the database is connected.

for example: DataSource=(LocalDB)\\MSSQLLocalDB;AttachDbFilename= C:\\Werkzeugdatenbank\\Datenbanken\\Werkzeuge.mdf ;Integrated Security = True; Connect Timeout = 30

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM