Solved

SQL Connection String

Posted on 2009-05-20
2
704 Views
Last Modified: 2013-11-27
Hello,

I am using SQL Server Express 2008 with a Console application. I have created a local database called Database.mdf, but I am wondering what the connection string would be and how to add a record from within the the console app.

I have only used windows forms prior to this so have only drag and dropped but as there is no form I am a bit unsure.

Any help would be appreciated.

Thanks,
0
Comment
Question by:DanielJay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 250 total points
ID: 24433407
The connection string will be the same in the console app as in a Windows Forms app.  As always, your best source on these is http://connectionstrings.com/sql-server-2008

To add a record, you're going to want a SqlCommand object and you'll want to set it's CommandText to an INSERT statement:

Dim cmd as SqlCommand
cmd = new SqlCommand("Insert Into MyTable(Field1, Field2) Values (1, 'hi')", MySqlConn)
cmd.ExecuteNonQuery()
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 24433866
As DanielWilson said, you can refer http://www.connectionstrings.com/ for connection string.

Regarding developing applications, you can see http://www.codeproject.com/

This has some examples that may help you in learning programming.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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