Solved

SQL Connection String

Posted on 2009-05-20
2
705 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

728 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