.net
how to connect to db
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manoj BhoirRank #599 · 4K reputationPosted Apr 30, 2015, 11:30 PM EDT
You will get so many example on Internet to connect your applicaion with database.
Sample Code :
using System;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string connetionString = null;
SqlConnection cnn ;
connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
cnn = new SqlConnection(connetionString);
try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
}
}
Please check these link :
How to connect SQL Database to your C# program, beginner's tutorial
http://www.codeproject.com/Articles/823854/How-to-connect-SQL-Database-to-your-Csharp-program
C# SQL Server Connection
http://csharp.net-informations.com/data-providers/csharp-sql-server-connection.htm
For more info about Conections strings for different types of Database
http://www.connectionstrings.com/
Riddhi ValechaRank #794 · 2.9K reputationPosted May 1, 2015, 3:05 AM EDT
Refer -
http://www.dofactory.com/reference/connection-strings
Hope this helps !
Khargesh RajputRank #616 · 3.9K reputationPosted May 1, 2015, 3:52 AM EDT
http://csharp.net-informations.com/data-providers/csharp-sql-server-connection.htm
Vincent Maverick DuranoRank #238 · 10.3K reputationPosted May 1, 2015, 10:55 AM EDT
This is a very generic question and can easily be found at google by doing a simple search. Also what database do you want to connect with? Which development platform? windows? web? What data access do you want to use for connecting to your database?
Adinarayana Reddy JcRank #7,298 · 244 reputationPosted May 8, 2015, 3:24 AM EDT
try this one.
http://adidotnettotal.blogspot.in/2013/03/registration-form-in-aspnet-using.html
Dipankar BiswasRank #992 · 2K reputationPosted May 8, 2015, 11:50 AM EDT
Oledb...
connectin:
SqlClient
Dim conn As New SqlClient.SqlConnection
conn = New SqlClient.SqlConnection