Solved

SQL Connection String

Posted on 2009-05-20
2
693 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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 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

7 Experts available now in Live!

Get 1:1 Help Now