Solved

SQL Connection String

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

16 Experts available now in Live!

Get 1:1 Help Now