How to run sql script included in application

Posted on 2015-02-14
Last Modified: 2015-02-14
I  have  four scripts  ,which I  use  to  deploy  along  with  my  exe  at  client  end.Scripts  use to create  database.
Now  it is  requirement  that,sepearate  script  files  should  not  be there.So  I  included  them  in  WPF  C#  application.
Now  I  have  to  give  path  of   them.How  can give  script  files  path  from  application.I  am  attaching  image  of  my  folder  structure.I  need  to  run script  from  project LumiQuant_ASW. Please  help
Question by:enthurao
  • 4

Accepted Solution

enthurao earned 0 total points
ID: 40609579
I  moved  file  to LumiQuant_ASW and  in  I  appended  path
 String strpath = AppDomain.CurrentDomain.BaseDirectory;
It  worked  perfectly

Author Comment

ID: 40609583
very  sorry  to  inform  this  solution  does  not  work. I  found  no  option  to  reopen  the  question.
Actually  solution  runned  once  because  by  mistake  script  files  where  present in  debug  folder.
The  main  question  how  to  use  files  in  application  and  not  on  physical  drive.Please  reopen
the question.

Author Comment

ID: 40609629
Now I  found  perfect  solution  which  worked.
I  renamed  .sql files  to .txt
Added those  files in project.
right clicked  files and opened properites,set  build action to"Embeded Resources"

  Assembly _assembly;
  _assembly = Assembly.GetExecutingAssembly();

Author Comment

ID: 40609630

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now