asp.net SQL Server connection string in C #

Source: Internet
Author: User
Tags sql server connection string

ODBC: Connecting to databases

The code is as follows Copy Code

Driver={sql Server}; server=rousecms.hostedresource.com; Database=rousecms; Uid=rousecms; pwd= ' Your password ';


OLE DB, OleDbConnection (. NET): Connecting to a database

The code is as follows Copy Code

Provider=sqloledb; Data source=rousecms.hostedresource.com; Initial Catalog=rousecms; User Id=rousecms; Password= ' Your Password ';


Provider=sqloledb; Server=meteor-pc;database=rousecms; Uid=sa; pwd=123456


SqlConnection (. NET):

The code is as follows Copy Code


Data source=rousecms.hostedresource.com; Initial Catalog=rousecms; User Id=rousecms; Password= ' Your Password ';

Cases

Connecting in. Net

The code is as follows Copy Code

System.Data
System.Data.SqlClient

public void Page_Load ()
{
Sqlconnetion myconnetion=new sqlconnetion ();
myconnetion.sqlconnetionstring= "User id=sa;password=***;initial catalog=testdatabase;data source=mySqlServer";
Myconnetion.open ();
}

Cases

  code is as follows copy code

connstr= " Data source= ' AAA '; uid=;p wd=;d atabase= ' sss '
Data source
UID user name
pwd password
database name;
2, if it's Winnt Card mode connstr to add Trusted_connection=yes
3, remote connection and local connection, just modify data source

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.