As of now I've been given a piece of software that reads XML files and presents these graphically, to give the user some overview to the events these files describe.
The crux as of now is that one of the engineers using the software has requested that all the data you load into the program should be possible to save to a database.
My pickle is as follows:
public void addToDBO(List<List<EventElement>> insertList)
{
SqlConnection s1 = new SqlConnection();
s1.ConnectionString = filePath;
s1.Open();
SqlCommand command = new SqlCommand();
command.Connection = s1;
foreach (List<EventElement> item in insertList)
---------------------SNIP----------------------------
//Adding-data-to-database logic
I mean to write the loaded data into a database deployed localy, but the the problem is that it does not accept my hamhanded methods of simply adding the database's filepath as the filepath
string.
So, to summarize: How do I correctly connect to a database situated on my C:/?
Thank you in advance.
You do not simply pass a file path. The connection string needs to follow a certain convention. For example
Provider=SQLNCLI10;Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;
Database=dbname;Trusted_Connection=Yes;
See http://www.connectionstrings.com/sql-server/ for more
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.