How to attach sql database file to creating .exe setup in c#

I create a Setup file and put data folder, in data folder i put database file , but the problem is i have to mannualy attach database file in sql server 2005. I have to automatically attach database file when installing setup file.

Hi
bhagvad,
Welcome to MSDN Forums!
We can implement auto attach database just use the connection string following.
1)      
Add a folder named ”DB” to the project, and copy the database file into it after you detach it from your sql server.
2)      
Change your connection string like this:
    <connectionStrings>
        <add name="WindowsFormsApplication1.Properties.Settings.BabakConnectionString"
            connectionString="Data Source=.;AttachDbFilename=|DataDirectory|\DB\Babak.mdf;Initial Catalog=test;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
3)      
After these, the database file will auto attach to the sql server when you run your application, and the database name is “test”, you can open the sql server
management studio to find it.
In addition, you can find the connection in the app.config file through the solution explorer in vs2010. And you also can find this file under your project. With
these information, you can find it and modify it.
If there’s anything unclear, please feel free to let me know.
Best wishes,
Mike
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually
answer your question. This can be beneficial to the others community members reading the thread.
when i try this i have an error from the computer. in my computer just microsoft server 2005 installed. and i need to setup my project. 
<add name="TelekomEthernetApp.Properties.Settings.TelekomEthernetConnectionString" 
       connectionString="Data Source=.;AttachDbFilename=|DataDirectory|\DB\TelekomEthernet.mdf;Initial Catalog=test;Integrated security=true" providerName="System.Data.SqlClient"/>
what is the problem?
http://img31.imageshack.us/img31/2305/asdet.png

Similar Messages

  • How to locate SQL database files

    Over the years I've used and discarded any number of applications, many of which created SQL databases.  I'm trying to clean out various odds and ends and would like to know how to search for anything SQL.  I know, for instance, that mail.app uses SQL but I have no idea where to find the database (not that I want to delete Mail!). 
    I'm comfortable using Terminal if that's the way to go.
    Any tips on locating hidden SQL databases would really be appreciated.
    Thanks!

    Similar to when users delete mailbox content, moving user mailboxes doesn't reduce the size of the edb file.  Instead, the database simply gains "white space" which will be filled in before the edb grows any further.  Once your users
    are vacated, you can remove the databases from AD per the cmdlet mentioned above.  as a safety measure, that cmdlet doesn't delete the actual edb files, but once you've run it, yes, you just go and press the delete key on the files.  Obviously "ctrl+a"
    means all files, which isn't what we're talking about.  Just the database and associated log files.
    Mike Crowley | MVP
    My Blog --
    Baseline Technologies

  • How to attach/restore the sql database/file extension (*.File)

    I took backup the database long back ago. Now I
    am unable to attach/restore the sql database/file extension (*.File). I
    have the file type called (*.File) which i need to attach/restore. Can anyone tell me what's are the steps
    taken to do this? 
    Thank in advance.

    Database
    name-->Right Click-->Tasks-->Restore-->Database-->Select "Device" radio button-->Click device Path button-->Click "ADD" button --> I tried with "All Files(*)"--> then i selected my database-->ok-->ok-->ok -->
    then i am getting below error. 
    I am unable to post image. 
    "Restore of database 'Databasename' failed. (microsoft.sqlserver.management.relationalenginetasks)"
    Additional Information:
    System.Data.SqlClient.SqlError: The database was backed up on a server running version 8.00.0194. That version is incompatible with this server, which is running version 11.00.2100. Either
    restore the database on a server that supports the backup, or use a backup that is compatible with this server. (Microsoft.SqlServer.SmoExtended).
    Can
    you please help me to solve this error.
    Thanks,
    Laxmi.

  • How to specify the database file path when create FDM application

    Dear All,
    How to specify the database file path (MSSQL) when create FDM application?
    Right now, all data file are placed in the D:\ . I want to specify the database files (log and mdf file) in other place. How to do it?
    Thanks.

    Where is the highS2.xml located on the disk? If you add it to your project you should set its Build Action to Content and its Copy To Output Directory to Always in Visual Studio:
    Please remember to close your threads by marking helpful posts as answer once your issue has been solved and then start a new thread if you have a new question.

  • How to generate .SQL format file from oracle database?

    How to generate .SQL format file from oracle database?
    I have a database of Oracle 8.1.6,now want to generate script file (including table structure,index,etc.) from it,What should I do?
    Thanks.

    Your question pertains to the Database Export/Import. This forum exclusively focusses on the export/import utilities that come along with "Oracle Portal" which is a web-based tool. Could you please post your question under the RDBMS export/import or migration forum.

  • How to move SQL database from one location to another location i.e. from C' drive to D' drive

    Hi, How to move SQL database from one location to another location i.e. from C' drive to D' drive ? please share some link.
    Thanks and Regards, Rangnath Mali

    Hi Rangnath,
    According to your description, my understanding is that you want to move databased from C drive to D drive.
    You can detach Database so that the files become independent, cut and paste the files from source to destination and attach again.
    There are two similar posts for your reference:
    http://mssqltalks.wordpress.com/2013/02/28/how-to-move-database-files-from-one-drive-to-another-or-from-one-location-to-another-in-sql-server/
    http://stackoverflow.com/questions/6584938/move-sql-server-2008-database-files-to-a-new-folder-location
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • How to attach a text file as an attachment to email message?

    Hello Everybody,
    I have a .csv file, in which details about emp-id, emp-name, e-expenses for Reimbursement and email address are stored.
    My application reads this .csv file, and sends a mail to each employee with his id, salary details in text format. (by changing content type to "text/plain") The code is working fine. But,
    My problem is:
    The message is sent as message body to the end user.
    The end user / the person who receives this mail will not be a technical person. So,
    1) If he trys to take a print out of this e-mail, He get only half of it.(as no. of colums will be more than paper size).
    2) I am finding alignment problem. IF employee name is too big, other columns will shift to right and data will not be exactly under column header. (it is going in zig zag way)
    So, I thought sending text file with all the details as an attachment might do well.
    But, I don't know how to attach a text file to email-message body.
    code
    try
                   {               String s1="";
                                  File f1 = new File(the path);
                                  FileInputStream fstream = new FileInputStream(f1); //new
                                  BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
                                  int count=0;
                                  while((s1=br.readLine())!=null )
                                                 count++;
                                                 //out.println("within while loop "+count);
                                                 StringTokenizer st = new StringTokenizer(s1,",");
                                                 if ((st.hasMoreTokens())&&(count>1))
                                            String a=st.nextToken().trim();
                                                 String b=st.nextToken();
                                                 String c=st.nextToken();
                                                 String d=st.nextToken();
                                                 String e=st.nextToken();
                                                 String f=st.nextToken();
                                                 String g=st.nextToken();
                                                 String h=st.nextToken();
                                                 String i=st.nextToken();
                                                 String j=st.nextToken();
                                                 String k=st.nextToken();
                                                 String l=st.nextToken();
                                                 String m=st.nextToken();
                                                 String n=st.nextToken();
                                                 String o=st.nextToken();
                                                 String p=st.nextToken();
                                                 String q=st.nextToken();
                                                 String mail=st.nextToken();
                                                 String s=st.nextToken();
                                                 //out.println("b="+b+"c="+c+"d="+d+"e="+e+"f="+f+"mail="+mail);
                                                 %>
    <%
                                            String to =mail;
                                                 String from =request.getParameter("fromadd");                                        
                                                 String subject ="Statement of Expenses";
                                                 String smtp ="mail.xxxxxxxxxx.com";
                                                 String message="";                                        
                                                 message=message.concat("EMP ID");
                                                 message=message.concat("     ");
                                                 message=message.concat("Name");
                                                 message=message.concat("          ");
                                                 message=message.concat("Dept No.");
                                                 message=message.concat("     ");
                                                 message=message.concat("Acc No.");
                                                 message=message.concat("     ");
                                                 message=message.concat("*****************************************************************************************");     
                                                 message=message.concat(a);
                                                 message=message.concat("     ");
                                                 message=message.concat(b);
                                                 message=message.concat("          ");
                                                 message=message.concat(c);
                                                 message=message.concat("     ");
                                                 message=message.concat(d);
                                                 Properties props = System.getProperties();
                                                 // Puts the SMTP server name to properties object
                                                 props.put("mail.smtp.host", smtp);
                                                 // Get the default Session using Properties Object
                                                 Session session1 = Session.getDefaultInstance(props, null);
                                                 // Create a New message
                                                 MimeMessage msg = new MimeMessage(session1);
                                                 // Set the From address
                                                 msg.setFrom(new InternetAddress(from));
                                                 // Setting the "To recipients" addresses
                                            msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
                                            /* // Setting the "cc recipients" addresses
                                            msg.setRecipients(Message.RecipientType.CC,InternetAddress.parse(cc, false));
                                            // Setting the "Bcc recipients" addresses
                                            msg.setRecipients(Message.RecipientType.BCC,InternetAddress.parse(bcc, false)); */
                                            // Sets the Subject
                                            msg.setSubject(subject);
                                            // set the meaasge in HTML format
                                            msg.setContent(message,"text/plain");
                                            // Set the Date: header
                                            msg.setSentDate(new java.util.Date());
                                            // Send the message
                                            Transport.send(msg);
                                            // Display Success message
                                            result =result.concat("<tr><td>"+b+"</td>"+"<td>"+to+"</td></tr>");
                                                      }//end of if of hasmore element
                                       }// end of while loop
                        out.println(result);                    
    }catch(Exception e)
                        // If here, then error in sending Mail. Display Error message.
                        result="Unable to send your message";
                        out.println("e="+e);
    Any help will be appreciated.
    Thanks and regards.
    Ashvini

    <html>
    <p>
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setText("Your Messages");
    MimeBodyPart mbp2 = new MimeBodyPart();
    FileDataSource fds = new FileDataSource("Your Attachments");
    mbp2.setDataHandler(new DataHandler(fds));
    mbp2.setFileName(fds.getName());
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    mp.addBodyPart(mbp2);
    msg.setContent(mp);
    msg.saveChanges();
    msg.writeTo(System.out);
    msg.setSubject(subject);
    Transport.send(msg);
    </p>
    <B><U>See you can add above code in your program and see the magic</U></B>
    Bye
    regards--
    Ashish
    </html>

  • Can any one tell me how to attach a pdf file to the mail through workflow

    I have a smart which i am able  to convert it to a pdf file...now.. can any one tell me how to attach a pdf file to the mail through workflow

    Hi,
    To create the task for attachment
    Use the BOR SELFITEM and method NOTES_APPEND.
    The out come of this task contain a link called attachment with a clip attached. Clisk on that icon and choose the type of attachment u want . RAW , EXCEL , TXT , PDF... Then using the import icon u can attach the document u like.
    But the TYPE : OBJ.
    Similarly using NOTE_DISPLAY method u can display the documents u like.
    In any work item u have the facility to attach any atttchment for further circulation .
    Attchment @ WORKITEM
    1.Click the workitem for which you want to create the attchment
    2.Press create attachment
    3. Add the attachment u like (PDF)
    Reward points for useful answer.
    Richard A

  • How to restore sql database in Private Azure Cloud subscription?

    I want to restore my database bacpac file
    into Private
    cloud Azure Subscription but I do not get any option in Azure portal :(
    Is there any way to do this? 
    questions I asked here at stackoverflow 
    http://stackoverflow.com/questions/28847844/how-to-restore-sql-database-in-private-azure-cloud-subscription

    Hi itsashuthinks,
    Currently for private cloud Azure there is no Import/Export Service to import your BACPAC file into SQL Database.
    Because of this you will need to use client tools. 
    The process to do this is the following.
    Open SSMS and connect to your cloud server.
    Right click on "Databases" under your server in object explorer and select import data-tier application.
    Follow the import wizard instructions to start the import.
    Learn more about Data-tier applications and migrations here: https://msdn.microsoft.com/en-us/library/ee210546.aspx
    Hope this helps!

  • How to organize RAC database files on ASM

    How to Organize RAC database files on ASM.
    Say,
    DISK Group = DATA
    DISK Group= FLASH
    Instance = prod1, prod2
    '+DATA/PROD/datafiles/'
    or
    Need to Organize sepratly for each instance specific db files.
    as
    '+DATA/PROD1/datafiles'
    '+DATA?PROD2/datafiles'
    Thanks in Advance,
    Regards
    Satish

    It would be just PROD - since that's the database name...and BTW, when you use DBCA to create a database using ASM, it organizes data files under PROD and it doesn't use instance names.
    HTH
    Thanks
    Chandra

  • How to attach a PDF file TO the form so that recipients can access the file as a resource?

    How to attach a PDF file TO the form so that recipients can access the file as a resource?

    Sorry we do not support this. What you can do though is add a Formatted Text element and add a link to a PDF. To insert a link add some text, select the text and right click on the text (or look under the Insert menu in the top right of the scene)
    Gen

  • How to attach a .pld file in oracle Designer

    When we try to generate a form out of designer we are getting the error ilke
    sample.pld file is required. The Questions on it are,
    1. What is a .pld file in a designer mean.
    2. How to attach a .pld file in oracle designer for the generation of forms.
    Thanks,
    Ramesh.R

    Hi Erik,
    Thanks for the update.
    My problem in designer is in the desginer under the generator preference dialog window the property "Form/Libr" attachment the "module specific library attachment" has the value like "ABC". I am having ABC.pld file in my system. I have included the file path in the pll file path in the Generator options tab.
    While generating the forms from designer i am getting the error "CDG-01373 ERROR: Module ABC: Unable to attach library ABC".
    My Questions are how to attach the ABC.pld file for this error. Thanks in advance
    Thanks,
    Ramesh.R

  • Basic question on SQL database file structure

    I'm learning to use JDBC / databases . I'm using JBuilder3 professional and HSQL (aka Hypersonic). I've
    been following the Java Tutorial on learning databases.
    So far I've sucessfully
    set up the drivers / URL etc
    connected to the URL
    created a database (COFFEEBREAK , as per the tutorial)
    added tables
    added data
    queried the database
    ------------- with the tutorial , so far so good. --------
    My only database experience prior to this was using Microsoft access, where tables, data, queries etc are all
    stored in one file <myfile.mdb>
    But with the example I am following, not one but 4 files have been created:
    COFFEEBREAK.data
    COFFEEBREAK.backup
    COFFEEBREAK.properties
    COFFEEBREAK.script
    the COFFEEBREAK.data file, looks like this (one line) in a text editor:
    padding="0" cell
    After I added data , using SQL ,I was expecting this file to grow ("as data rows were added") , but no change at all - still just one line.
    The file that DOES change is the COFFEEBREAK.script file. The SQL instructions get added to the end of the file eg :
    <various lines>
    INSERT INTO FILES VALUES('.\COFFEEBREAK.properties','COFFEEBREAK.properties')
    INSERT INTO FILES VALUES('.\COFFEEBREAK.data','COFFEEBREAK.data')
    INSERT INTO COFFEES VALUES('French_Roast',49,8.99,0,0)
    INSERT INTO COFFEES VALUES('Espresso',150,9.99,0,0)
    INSERT INTO COFFEES VALUES('Colombian_Decaf',101,8.99,0,0)
    INSERT INTO COFFEES VALUES('French_Roast_Decaf',49,9.99,0,0)
    I had been expecting a single file ( a la Microsoft access) , with the data in it and not readable in ascii form.
    Am I misunderstanding the structure of SQL / DBMS files , or is this just a pecularity of Hypersonic ??
    How do I ship a finished Java application where a database can be interrogated - will the *.script file have to be shipped too? If so , all the data is there , so how is the DBMS password protected?
    I'm confused ! Thanks in advance
    M.

    Thanks again for the response trejkaz.
    If the database were encrypted, you could just use an ordinary SQL query tool to dump >> all the records to a text file, which would be just as readable as the .script file!I had in mind if the user name was "Bill" with his (self selected ) password "hisPass" then the encryption key would be derived from a mangled version of those two bits of data (eg qazBillwsxhisPass or whatever). As long as the mangling mechanism was secret hopefully that would stop access through regular SQL query tools.
    You're giving them the software to read the database anyway .. what's the difference if they >> read the info from the flat file, compared to reading it through a program? Through the program the data is view only (maybe with a limited subset of the fields for printing). With a flat file a potential competitor gets a jump start by having an electronic copy to bootleg.
    Two examples occurred to me, one simple & one closer to what I'm trying to achieve
    1) An example of a multiple choice database for students where the computer tells them how they have done - couldnt the students just look up the answers beforehand in the script file ?
    2) (hypothetical example) Suppose I'm an expert on gardening & I want to set up 'electronic garden advice' Inc. I prepare a database, say about 3000 records. A typical record may have a layout based on :
    question
    question ref. number
    region
    garden style ref.
    plant type main
    plant type sub
    disease-prone?
    commercial/non commercial
    criticality weighting %
    substitute plants
    recommended treatments
    preferred season
    etc . Most of us can imagine more possible fields
    Anyone can pay the $ , download the database & set themselves up as an expert, maybe extracting sub sets of the data, depending on their customers needs.
    But any printouts might only have say the question & question number so the whole database woulnd't be printed to a text file from my Java app . (The non printed fields are used within the Java app say for cross referencing alternatives etc) so the whole database couldn't be downloaded via a print routine to a text file.
    At the moment my options seem to be:
    1) different SQL database , where the data isnt stored in ascii readable form
    2) Just use a csv text file instead of dbms & write my own encryption
    3) Encrypt the HSQL script file, have the java app decrypt it to a temp scratch file & load that way . (the problem there seems that in a multitasking OS, the user just copies the scratch file)
    4) somehow do the decryption after loading from an encrypted script file but before presenting the data on screen.
    5) any other ideas you can recommend...?!
    Apologies for the long response, my thoughts on this are still evolving
    Thanks again
    Mike2z

  • Attach sql MDB file for JDBC

    how to connect the sql server database(attach the MDB file in the root folder).Please help me
    Pon saravanan
    [GridView Paging|http://www.vbknowledgebase.com/?Id=69&Desc=Asp-.Net-GridView-Paging]

    pons_saravanan wrote:
    how to connect the sql server database(attach the MDB file in the root folder).Please help me
    Pon saravananNo link sigs!

  • How to query a database file on my hard drive?

    Hi,
    I have a filer called "server.dbs" on my hard drive. It is a database file. I use a simple program that allows you to view databases, and it loads up and I can traverse the database and see all the entries as any standard database.
    So I figured that Java's ability to handle SQL would allow me to make a standard SQL statement querying the database, and be able to get the results. The software stores servers in SID fields, and the value is the port the server runs on. I want to make a simple query to select a server by SID, and print the port in which that server is running on.
    So is there any way to, via my java application, load a database from a file (rather than a url) which has no authentication required, and simply make my queries directly to that file? If so, how?
    Thanks!
    -Josh

    Normal database access is via JDBC.
    http://java.sun.com/docs/books/tutorial/jdbc/index.html
    To use that JDBC driver is needed to access the database. Databases in wide usage all have one. It isn't clear from your posting that you have a common database though.

Maybe you are looking for