若天明 发表于 2015-1-16 22:40:58

ASP网页编程之.NET中各类数据库毗连年夜全

对于中小型web应用来说,php有很强的竞争力,linux+apache+mysql+php(lamp)的组合几乎可以胜任绝大多数网站的解决方案,对于大型应用来讲,对于系统架构要求更高,需要有成熟的框架支持,jsp的struts是个不错的框架,国内介绍它的资料也非常多,应用逐渐广泛起来。asp就不用说了,SQLServer
ODBC

StandardSecurity:
"Driver={SQLServer};Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd;"

Trustedconnection:
"Driver={SQLServer};Server=Aron1;Database=pubs;Trusted_Connection=yes;"

Promptforusernameandpassword:
oConn.Properties("Prompt")=adPromptAlways
oConn.Open"Driver={SQLServer};Server=Aron1;DataBase=pubs;"

OLEDB,OleDbConnection(.NET)

StandardSecurity:
"Provider=sqloledb;DataSource=Aron1;InitialCatalog=pubs;UserId=sa;Password=asdasd;"

TrustedConnection:
"Provider=sqloledb;DataSource=Aron1;InitialCatalog=pubs;IntegratedSecurity=SSPI;"
(useserverNameinstanceNameasDataSourcetouseanspecifikSQLServerinstance,onlySQLServer2000)
Promptforusernameandpassword:
oConn.Provider="sqloledb"
oConn.Properties("Prompt")=adPromptAlways
oConn.Open"DataSource=Aron1;InitialCatalog=pubs;"

ConnectviaanIPaddress:
"Provider=sqloledb;DataSource=190.190.200.100,1433;NetworkLibrary=DBMSSOCN;InitialCatalog=pubs;UserID=sa;Password=asdasd;"
(DBMSSOCN=TCP/IPinsteadofNamedPipes,attheendoftheDataSourceistheporttouse(1433isthedefault))
SqlConnection(.NET)

StandardSecurity:
"DataSource=Aron1;InitialCatalog=pubs;UserId=sa;Password=asdasd;"

TrustedConnection:
"DataSource=Aron1;InitialCatalog=pubs;IntegratedSecurity=SSPI;"
(useserverNameinstanceNameasDataSourcetouseanspecifikSQLServerinstance,onlySQLServer2000)
ConnectviaanIPaddress:
"DataSource=190.190.200.100,1433;NetworkLibrary=DBMSSOCN;InitialCatalog=pubs;UserID=sa;Password=asdasd;"
(DBMSSOCN=TCP/IPinsteadofNamedPipes,attheendoftheDataSourceistheporttouse(1433isthedefault))
DeclaretheSqlConnection:
C#:
usingSystem.Data.SqlClient;
SqlConnectionoSQLConn=newSqlConnection();
oSQLConn.ConnectionString="myconnectionstring";
oSQLConn.Open();
VB.NET:
ImportsSystem.Data.SqlClient
DimoSQLConnAsSqlConnection=NewSqlConnection()
oSQLConn.ConnectionString="myconnectionstring"
oSQLConn.Open()

DataShape

MSDataShape
"Provider=MSDataShape;DataProvider=SQLOLEDB;DataSource=Aron1;InitialCatalog=pubs;UserID=sa;Password=asdasd;"

Readmore

Howtodefinewichnetworkprotocoltouse

Example:
"Provider=sqloledb;DataSource=190.190.200.100,1433;NetworkLibrary=DBMSSOCN;InitialCatalog=pubs;UserID=sa;Password=asdasd;"
NameNetworklibrary
dbnmpntwWin32NamedPipes
dbmssocnWin32WinsockTCP/IP
dbmsspxnWin32SPX/IPX
dbmsvinnWin32BanyanVines
dbmsrpcnWin32Multi-Protocol(WindowsRPC)

Importantnote!
WhenconnectingthroughtheSQLOLEDBproviderusethesyntaxNetworkLibrary=dbmssocn
andwhenconnectingthroughMSDASQLproviderusethesyntaxNetwork=dbmssocn

AllSqlConnectionconnectionstringproperties

ThistableshowsallconnectionstringpropertiesfortheADO.NETSqlConnectionobject.MostofthepropertiesarealsousedinADO.Allpropertiesanddescriptionsisfrommsdn.
NameDefaultDescription
ApplicationNameThenameoftheapplication,or.NetSqlClientDataProviderifnoapplicationnameisprovided.
AttachDBFilename
-or-
extendedproperties
-or-
InitialFileNameThenameoftheprimaryfile,includingthefullpathname,ofanattachabledatabase.Thedatabasenamemustbespecifiedwiththekeyworddatabase.
ConnectTimeout
-or-
ConnectionTimeout15Thelengthoftime(inseconds)towaitforaconnectiontotheserverbeforeterminatingtheattemptandgeneratinganerror.
ConnectionLifetime0Whenaconnectionisreturnedtothepool,itscreationtimeiscomparedwiththecurrenttime,andtheconnectionisdestroyedifthattimespan(inseconds)exceedsthevaluespecifiedbyconnectionlifetime.Usefulinclusteredconfigurationstoforceloadbalancingbetweenarunningserverandaserverjustbroughton-line.
ConnectionResettrueDetermineswhetherthedatabaseconnectionisresetwhenbeingremovedfromthepool.Settingtofalseavoidsmakinganadditionalserverround-tripwhenobtainingaconnection,buttheprogrammermustbeawarethattheconnectionstateisnotbeingreset.
CurrentLanguageTheSQLServerLanguagerecordname.
DataSource
-or-
Server
-or-
Address
-or-
Addr
-or-
NetworkAddressThenameornetworkaddressoftheinstanceofSQLServertowhichtoconnect.
EnlisttrueWhentrue,thepoolerautomaticallyenliststheconnectioninthecreationthreadscurrenttransactioncontext.
InitialCatalog
-or-
DatabaseThenameofthedatabase.
IntegratedSecurity
-or-
Trusted_ConnectionfalseWhethertheconnectionistobeasecureconnectionornot.Recognizedvaluesaretrue,false,andsspi,whichisequivalenttotrue.
MaxPoolSize100Themaximumnumberofconnectionsallowedinthepool.
MinPoolSize0Theminimumnumberofconnectionsallowedinthepool.
NetworkLibrary
-or-
NetdbmssocnThenetworklibraryusedtoestablishaconnectiontoaninstanceofSQLServer.Supportedvaluesincludedbnmpntw(NamedPipes),dbmsrpcn(Multiprotocol),dbmsadsn(AppleTalk),dbmsgnet(VIA),dbmsipcn(SharedMemory)anddbmsspxn(IPX/SPX),anddbmssocn(TCP/IP).
ThecorrespondingnetworkDLLmustbeinstalledonthesystemtowhichyouconnect.Ifyoudonotspecifyanetworkandyouusealocalserver(forexample,"."or"(local)"),sharedmemoryisused.
PacketSize8192SizeinbytesofthenetworkpacketsusedtocommunicatewithaninstanceofSQLServer.
Password
-or-
PwdThepasswordfortheSQLServeraccountloggingon.
PersistSecurityInfofalseWhensettofalse,security-sensitiveinformation,suchasthepassword,isnotreturnedaspartoftheconnectioniftheconnectionisopenorhaseverbeeninanopenstate.Resettingtheconnectionstringresetsallconnectionstringvaluesincludingthepassword.
PoolingtrueWhentrue,theSQLConnectionobjectisdrawnfromtheappropriatepool,orifnecessary,iscreatedandaddedtotheappropriatepool.
UserIDTheSQLServerloginaccount.
WorkstationIDthelocalcomputernameThenameoftheworkstationconnectingtoSQLServer.

Note
Use;toseparateeachproperty.
Ifanameoccursmorethanonce,thevaluefromthelastoneintheconnectionstringwillbeused.
Ifyouarebuildingyourconnectionstringinyourappusingvaluesfromuserinputfields,makesuretheusercantchangetheconnectionstringbyinsertinganadditionalpropertywithanothervaluewithintheuservalue.
Access
ODBC

StandardSecurity:
"Driver={MicrosoftAccessDriver(*.mdb)};Dbq=somepathmydb.mdb;Uid=Admin;Pwd=asdasd;"

Workgroup:
"Driver={MicrosoftAccessDriver(*.mdb)};Dbq=somepathmydb.mdb;SystemDB=somepathmydb.mdw;","admin",""

OLEDB,OleDbConnection(.NET)

Standardsecurity:
"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=somepathmydb.mdb;UserId=admin;Password=asdasd;"

Workgroup(systemdatabase):
"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=somepathmydb.mdb;JetOLEDB:SystemDatabase=system.mdw;","admin",""

Withpassword:
"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=somepathmydb.mdb;JetOLEDB:DatabasePassword=MyDbPassword;","admin",""

Oracle
ODBC

Newversion:
"Driver={MicrosoftODBCforOracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;"

Oldversion:
"Driver={MicrosoftODBCDriverforOracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;"

OLEDB,OleDbConnection(.NET)

Standardsecurity:
"Provider=msdaora;DataSource=MyOracleDB;UserId=UserName;Password=asdasd;"
ThisonesfromMicrosoft,thefollowingarefromOracle
StandardSecurity:
"Provider=OraOLEDB.Oracle;DataSource=MyOracleDB;UserId=Username;Password=asdasd;"

TrustedConnection:
"Provider=OraOLEDB.Oracle;DataSource=MyOracleDB;OSAuthent=1;"

OracleConnection(.NET)

Standard:
"DataSource=Oracle8i;IntegratedSecurity=yes";
ThisoneworksonlywithOracle8irelease3orlater
DeclaretheOracleConnection:
C#:
usingSystem.Data.OracleClient;
OracleConnectionoOracleConn=newOracleConnection();
oOracleConn.ConnectionString="myconnectionstring";
oOracleConn.Open();
VB.NET:
ImportsSystem.Data.OracleClient
DimoOracleConnAsOracleConnection=NewOracleConnection()
oOracleConn.ConnectionString="myconnectionstring"
oOracleConn.Open()

DataShape

MSDataShape:
"Provider=MSDataShape.1;PersistSecurityInfo=False;DataProvider=MSDAORA;DataSource=orac;userid=username;password=mypw"

MySQL
ODBC

Localdatabase:
"Driver={mySQL};Server=mySrvName;Option=16834;Database=mydatabase;"

Remotedatabase:
"Driver={mySQL};Server=data.domain.com;Port=3306;Option=131072;Stmt=;Database=my-database;Uid=username;Pwd=password;"

OLEDB,OleDbConnection(.NET)

Standard:
"Provider=MySQLProv;DataSource=mydb;UserId=UserName;Password=asdasd;"
MySqlConnection(.NET)

EID:
"DataSource=server;Database=mydb;UserID=username;Password=pwd;CommandLogging=false"
ThisoneisusedwitheInfoDesignsdbProvider,anadd-onto.NET
DeclaretheMySqlConnection:
C#:
usingEID.MySqlClient;
MySqlConnectionoMySqlConn=newMySqlConnection();
oMySqlConn.ConnectionString="myconnectionstring";
oMySqlConn.Open();
VB.NET:
ImportsEID.MySqlClient
DimoMySqlConnAsMySqlConnection=NewMySqlConnection()
oMySqlConn.ConnectionString="myconnectionstring"
oMySqlConn.Open()

IBMDB2
OLEDB,OleDbConnection(.NET)fromms

TCP/IP:
"Provider=DB2OLEDB;NetworkTransportLibrary=TCPIP;NetworkAddress=XXX.XXX.XXX.XXX;InitialCatalog=MyCtlg;PackageCollection=MyPkgCol;DefaultSchema=Schema;UserID=MyUser;Password=MyPW"

APPC:
"Provider=DB2OLEDB;APPCLocalLUAlias=MyAlias;APPCRemoteLUAlias=MyRemote;InitialCatalog=MyCtlg;PackageCollection=MyPkgCol;DefaultSchema=Schema;UserID=MyUser;Password=MyPW"

Sybase
ODBC

Standard:
"Driver={SYBASESYSTEM11};Srvr=Aron1;Uid=username;Pwd=password;"

Intersolv3.10:
"Driver={INTERSOLV3.1032-BITSybase};Srvr=Aron1;Uid=username;Pwd=password;"

Informix
ODBC

Informix3.30:
"Dsn=;Driver={INFORMIX3.3032BIT};Host=hostname;Server=myserver;Service=service-name;Protocol=olsoctcp;Database=mydb;UID=username;PWD=myPwd

Informix-CLI2.5:
"Driver={Informix-CLI2.5(32Bit)};Server=myserver;Database=mydb;Uid=username;Pwd=myPwd"

DSN
ODBC

DSN:
"DSN=myDsn;Uid=username;Pwd=;"

FileDSN:
"FILEDSN=c:myData.dsn;Uid=username;Pwd=;"

Excel
ODBC

Standard:
"Driver={MicrosoftExcelDriver(*.xls)};DriverId=790;Dbq=C:MyExcel.xls;DefaultDir=c:mypath;"

OLEDB

Standard:
"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:MyExcel.xls;ExtendedProperties=Excel8.0;HDR=Yes;"
"HDR=Yes;"indicatesthatthefirstrowcontainscolumnnames,notdata
DBF/FoxPro
ODBC

standard:
"Driver={MicrosoftdBASEDriver(*.dbf)};DriverID=277;Dbq=c:mydbpath;"

OLEDB,OleDbConnection(.NET)

standard:
"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c:folder;ExtendedProperties=dBASEIV;UserID=Admin;Password="

Pervasive
ODBC

Standard:
"Driver={PervasiveODBCClientInterface};ServerName=srvname;dbq=@dbname"

UDL
UDL

UDL:
"FileName=c:myDataLink.udl;"




SQLServer是基于服务器端的中型的数据库,可以适合大容量数据的应用,在功能上管理上也要比Access要强得多。在处理海量数据的效率,后台开发的灵活性,可扩展性等方面强大。

冷月葬花魂 发表于 2015-1-19 21:12:51

Session:这个存储跟客户端会话过程的数据,默认20分钟失效

愤怒的大鸟 发表于 2015-1-28 05:56:55

完全不知道到底自己学的是什么。最后,除了教程里面说的几个例子,还是什么都不会。

海妖 发表于 2015-2-5 14:01:09

还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。

灵魂腐蚀 发表于 2015-2-11 23:54:33

Session:这个存储跟客户端会话过程的数据,默认20分钟失效

兰色精灵 发表于 2015-3-2 20:23:40

弱类型造成潜在的出错可能:尽管弱数据类型的编程语言使用起来回方便一些,但相对于它所造成的出错几率是远远得不偿失的。

活着的死人 发表于 2015-3-11 06:06:57

你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。

不帅 发表于 2015-3-17 22:09:16

从事这个行业,那么你可以学ASP语言,简单快速上手,熟练dreamweav排版,写asp代码,熟练photoshop处理图片,打好基础就行了

飘灵儿 发表于 2015-3-25 03:43:41

多看多学多思。多看一些关于ASP的书籍,一方面可以扩展知识面一方面可以鉴借别人是如何掌握、运用ASP的;多学善于关注别人,向同学老师多多学习,不论知识的大小;多思则是要将学到的知识灵活运用。
页: [1]
查看完整版本: ASP网页编程之.NET中各类数据库毗连年夜全