?
Solved

SQL Connection String

Posted on 2009-05-20
2
Medium Priority
?
706 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 750 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

800 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