




已阅读5页,还剩18页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Csharp ASP.NETC#c# 数据库连接大全 c# 数据库连接大全 SQL Server ODBC Standard Security:Driver=SQL Server;Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd; Trusted connection:Driver=SQL Server;Server=Aron1;Database=pubs;Trusted_Connection=yes; Prompt for username and password:oConn.Properties(Prompt) = adPromptAlwaysoConn.Open Driver=SQL Server;Server=Aron1;DataBase=pubs; OLEDB, OleDbConnection (.NET) Standard Security:Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd; Trusted Connection:Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI; (use serverNameinstanceName as Data Source to use an specifik SQLServer instance, only SQLServer2000)Prompt for username and password:oConn.Provider = sqloledboConn.Properties(Prompt) = adPromptAlwaysoConn.Open Data Source=Aron1;Initial Catalog=pubs; Connect via an IP address:Provider=sqloledb;Data Source=00,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd; (DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the Data Source is the port to use (1433 is the default)SqlConnection (.NET) Standard Security:Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd; Trusted Connection:Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI; (use serverNameinstanceName as Data Source to use an specifik SQLServer instance, only SQLServer2000)Connect via an IP address:Data Source=00,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd; (DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the Data Source is the port to use (1433 is the default)Declare the SqlConnection:C#:using System.Data.SqlClient;SqlConnection oSQLConn = new SqlConnection();oSQLConn.ConnectionString=my connectionstring;oSQLConn.Open(); VB.NET:Imports System.Data.SqlClientDim oSQLConn As SqlConnection = New SqlConnection()oSQLConn.ConnectionString=my connectionstringoSQLConn.Open() Data Shape MS Data ShapeProvider=MSDataShape;Data Provider=SQLOLEDB;Data Source=Aron1;Initial Catalog=pubs;User ID=sa;Password=asdasd; Read more How to define wich network protocol to useExample:Provider=sqloledb;Data Source=00,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd; Name Network library dbnmpntw Win32 Named Pipes dbmssocn Win32 Winsock TCP/IP dbmsspxn Win32 SPX/IPX dbmsvinn Win32 Banyan Vines dbmsrpcn Win32 Multi-Protocol (Windows RPC) Important note! When connecting through the SQLOLEDB provider use the syntax Network Library=dbmssocnand when connecting through MSDASQL provider use the syntax Network=dbmssocn All SqlConnection connectionstring propertiesThis table shows all connectionstring properties for the ADO.NET SqlConnection object. Most of the properties are also used in ADO. All properties and descriptions is from msdn. Name Default Description Application Name The name of the application, or .Net SqlClient Data Provider if no application name is provided. AttachDBFilename-or-extended properties-or-Initial File Name The name of the primary file, including the full path name, of an attachable database. The database name must be specified with the keyword database . Connect Timeout-or-Connection Timeout 15 The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. Connection Lifetime 0 When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by connection lifetime. Useful in clustered configurations to force load balancing between a running server and a server just brought on-line. Connection Reset true Determines whether the database connection is reset when being removed from the pool. Setting to false avoids making an additional server round-trip when obtaining a connection, but the programmer must be aware that the connection state is not being reset. Current Language The SQL Server Language record name. Data Source-or-Server-or-Address-or-Addr-or-Network Address The name or network address of the instance of SQL Server to which to connect. Enlist true When true, the pooler automatically enlists the connection in the creation thread s current transaction context. Initial Catalog-or-Database The name of the database. Integrated Security-or-Trusted_Connection false Whether the connection is to be a secure connection or not. Recognized values are true , false , and sspi , which is equivalent to true . Max Pool Size 100 The maximum number of connections allowed in the pool. Min Pool Size 0 The minimum number of connections allowed in the pool. Network Library-or-Net dbmssocn The network library used to establish a connection to an instance of SQL Server. Supported values include dbnmpntw (Named Pipes), dbmsrpcn (Multiprotocol), dbmsadsn (Apple Talk), dbmsgnet (VIA), dbmsipcn (Shared Memory) and dbmsspxn (IPX/SPX), and dbmssocn (TCP/IP). The corresponding network DLL must be installed on the system to which you connect. If you do not specify a network and you use a local server (for example, . or (local), shared memory is used. Packet Size 8192 Size in bytes of the network packets used to communicate with an instance of SQL Server. Password-or-Pwd The password for the SQL Server account logging on. Persist Security Info false When set to false , security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values including the password. Pooling true When true, the SQLConnection object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool. User ID The SQL Server login account. Workstation ID the local computer name The name of the workstation connecting to SQL Server. Note Use ; to separate each property.If a name occurs more than once, the value from the last one in the connectionstring will be used.If you are building your connectionstring in your app using values from user input fields, make sure the user can t change the connectionstring by inserting an additional property with another value within the user value. Access ODBC Standard Security:Driver=Microsoft Access Driver (*.mdb);Dbq=somepathmydb.mdb;Uid=Admin;Pwd=asdasd; Workgroup:Driver=Microsoft Access Driver (*.mdb);Dbq=somepathmydb.mdb;SystemDB=somepathmydb.mdw;,admin, OLEDB, OleDbConnection (.NET) Standard security:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=somepathmydb.mdb;User Id=admin;Password=asdasd; Workgroup (system database):Provider=Microsoft.Jet.OLEDB.4.0;Data Source=somepathmydb.mdb;Jet OLEDB:System Database=system.mdw;,admin, With password:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=somepathmydb.mdb;Jet OLEDB:Database Password=MyDbPassword;,admin, Oracle ODBC New version:Driver=Microsoft ODBC for Oracle;Server=OracleServer.world;Uid=Username;Pwd=asdasd; Old version:Driver=Microsoft ODBC Driver for Oracle;ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword; OLEDB, OleDbConnection (.NET) Standard security:Provider=msdaora;Data Source=MyOracleDB;User Id=UserName;Password=asdasd; This one s from Microsoft, the following are from OracleStandard Security:Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd; Trusted Connection:Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1; OracleConnection (.NET) Standard:Data Source=Oracle8i;Integrated Security=yes; This one works only with Oracle 8i release 3 or laterDeclare the OracleConnection:C#:using System.Data.OracleClient;OracleConnection oOracleConn = new OracleConnection();oOracleConn.ConnectionString = my connectionstring;oOracleConn.Open(); VB.NET:Imports System.Data.OracleClientDim oOracleConn As OracleConnection = New OracleConnection()oOracleConn.ConnectionString = my connectionstringoOracleConn.Open() Data Shape MS Data Shape:Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;user id=username;password=mypw MySQL ODBC Local database:Driver=mySQL;Server=mySrvName;Option=16834;Database=mydatabase; Remote database:Driver=mySQL;Server=;Port=3306;Option=131072;Stmt=;Database=my-database;Uid=username;Pwd=password; OLEDB, OleDbConnection (.NET) Standard:Provider=MySQLProv;Data Source=mydb;User Id=UserName;Password=asdasd; MySqlConnection (.NET) EID:Data Source=server;Database=mydb;User ID=username;Password=pwd;Command Logging=false This one is used with eInfoDesigns dbProvider, an add-on to .NETDeclare the MySqlConnection:C#:using EID.MySqlClient;MySqlConnection oMySqlConn = new MySqlConnection();oMySqlConn.ConnectionString = my connectionstring;oMySqlConn.Open(); VB.NET:Imports EID.MySqlClientDim oMySqlConn As MySqlConnection = New MySqlConnection()oMySqlConn.ConnectionString = my connectionstringoMySqlConn.Open() IBM DB2 OLEDB, OleDbConnection (.NET) from ms TCP/IP:Provider=DB2OLEDB;Network Transport Library=TCPIP;Network Address=XXX.XXX.XXX.XXX;Initial Catalog=MyCtlg;Package Collection=MyPkgCol;Default Schema=Schema;User ID=MyUser;Password=MyPW APPC:Provider=DB2OLEDB;APPC Local LU Alias=MyAlias;APPC Remote LU Alias=MyRemote;Initial Catalog=MyCtlg;Package Collection=MyPkgCol;Default Schema=Schema;User ID=MyUser;Password=MyPW Sybase ODBC Standard:Driver=SYBASE SYSTEM 11;Srvr=Aron1;Uid=username;Pwd=password; Intersolv 3.10:Driver=INTERSOLV 3.10 32-BIT Sybase;Srvr=Aron1;Uid=username;Pwd=password; Informix ODBC Informix 3.30:Dsn= ;Driver=INFORMIX 3.30 32 BIT;Host=hostname;Server=myserver;Service=service-name;Protocol=olsoctcp;Database=mydb;UID=username;PWD=myPwd Informix-CLI 2.5:Driver=Informix-CLI 2.5 (32 Bit);Server=myserver;Database=mydb;Uid=username;Pwd=myPwd DSN ODBC DSN:DSN=myDsn;Uid=username;Pwd=; File DSN:FILEDSN=c:myData.dsn;Uid=username;Pwd=; Excel ODBC Standard:Driver=Microsoft Excel Driver (*.xls);DriverId=790;Dbq=C:MyExcel.xls;DefaultDir=c:mypath; OLE DB Standard:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:MyExcel.xls;Extended Properties=Excel 8.0;HDR=Yes; HDR=Yes; indicates that the first row contains columnnames, not dataDBF / FoxPro ODBC standard:Driver=Microsoft dBASE Driver (*.dbf);DriverID=277;Dbq=c:mydbpath; OLEDB, OleDbConnection (.NET) standard:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:folder;Extended Properties=dBASE IV;User ID=Admin;Password= Pervasive ODBC Standard:Driver=Pervasive ODBC Client Interface;ServerName=srvname;dbq=dbname UDL UDL posted on 2005-07-25 10:52 bobomail 阅读(254) 评论(6) 编辑收藏 评论#re: c# 数据库连接大全 2005-07-25 12:57 caravarn 数据库操作类 /pub/disp/Article?columnID=322&articleID=41083&pageNO=1 #re: c# 数据库连接大全 2005-07-25 15:58 caravarn 创建 c# 到 excel 2003 的连接驱动 /创建一个数据链接 string strCon = Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = c:sample.xls;Extended Properties=Excel 8.0 ; OleDbConnection myConn = new OleDbConnection ( strCon ) ; string strCom = SELECT * FROM Sheet1$ ; myConn.Open ( ) ; file:/打开数据链接,得到一个数据集 OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , myConn ) ; file:/创建一个 DataSet对象 myDataSet = new DataSet ( ) ; file:/得到自己的DataSet对象 myCommand.Fill ( myDataSet , Sheet1$ ) ; file:/关闭此数据链接 myConn.Close ( ) ; #re: c# 数据库连接大全 2005-07-25 15:59 caravarn /xiya/articles/36020.html #re: c# 数据库连接大全 2005-07-25 18:23 caravarn c# 随机数 /htm/center/prog/02_9_12_3.asp #re: c# 数据库连接大全 2005-08-04 16:49 caravarn /develop/article/28/28470.shtm #re: c# 数据库连接大全 2005-08-04 16:50 caravarn 这个 c# winfom 的 datagrad1 的操作 添加评论9:44:57|固定链接 | 引用通告 (0) | 记录它 | WEB开发固定链接关闭/blog/cns!32F0FA0361376772!125.entry8月11日ASPASP实现Web打印技术大全1、控制纵打、横打”和“页面的边距。(1)functionSetPrintSettings()/-advancedfeaturesfactory.printing.SetMarginMeasure(2)/measuremarginsininchesfactory.SetPageRange(false,1,3)/needpagesfrom1to3factory.printing.printer=HPDeskJet870Cfactory.printing.copies=2factory.printing.collate=truefactory.printing.paperSize=A4factory.printing.paperSource=Manualfeed/-basicfeaturesfactory.printing.header=ThisisMeadCofactory.printing.footer=AdvancedPrintingbyScriptXfactory.printing.portrait=falsefactory.printing.leftMargin=1.0factory.printing.topMargin=1.0factory.printing.rightMargin=1.0factory.printing.bottomMargin=1.0(2)functionprintsetup()/打印页面设置wb.execwb(8,1);functionprintpreview()/打印页面预览wb.execwb(7,1);functionprintit()if(confirm(确定打印吗?)wb.execwb(6,6)-关于这个组件还有其他的用法,列举如下:WebBrowser.ExecWB(1,1)打开Web.ExecWB(2,1)关闭现在所有的IE窗口,并打开一个新窗口Web.ExecWB(4,1)保存网页Web.ExecWB(6,1)打印Web.ExecWB(7,1)打印预览Web.ExecWB(8,1)打印页面设置Web.ExecWB(10,1)查看页面属性Web.ExecWB(15,1)好像是撤销,有待确认Web.ExecWB(17,1)全选Web.ExecWB(22,1)刷新Web.ExecWB(45,1)关闭窗体无提示2、分页打印Ppage-break-after:always3、ASP页面打印时如何去掉页面底部的路径和顶端的页码编号(1)ie的文件-页面设置-讲里面的页眉和页脚里面的东西都去掉,打印就不出来了。(2)NewDocumentdimhkey_root,hkey_path,hkey_keyhkey_root=HKEY_CURRENT_USERhkey_path=SoftwareMicrosoftInternetExplorerPageSetup/设置网页打印的页眉页脚为空functionpagesetup_null()onerrorresumenextSetRegWsh=CreateObject(WScript.Shell)hkey_key=headerRegWsh.RegWritehkey_root+hkey_path+hkey_key,hkey_key=footerRegWsh.RegWritehkey_root+hkey_path+hkey_key,endfunction/设置网页打印的页眉页脚为默认值functionpagesetup_default()onerrorresumenextSetRegWsh=CreateObject(WScript.Shell)hkey_key=headerRegWsh.RegWritehkey_root+hkey_path+hkey_key,&w&b页码,&p/&Phkey_key=footerRegWsh.RegWritehkey_root+hkey_path+hkey_key,&u&b&dendfunction4、浮动帧打印functionbutton1_onclick()varodoc=window.iframe1.document;varr=odoc.body.createTextRange();varstxt=r.htmlText;alert(stxt)varpwin=window.open(,print);pwin.document.write(stxt);pwin.print();4、用FileSystem组件实现WEB应用中的本地特定打印functionprint_onclick/打印函数dimlabellabel=document.printinfo.label.value/获得HTML页面的数据setobjfs=CreateObject(Scripting.FileSystemObject)/创建FileSystem组件对象的实例setobjprinter=objfs.CreateTextFile(LPT1:,true)/建立与打印机的连接objprinter.Writeline(_)/输出打印的内容objprinter.Writeline(|)objprinter.Writeline(|您打印的数据是:&label&|”)objprinter.Writeline(|)objprinter.Writeline(|_|)objprinter.close/断开与打印机的连接setobjprinter=nothingsetobjfs=nothing/关闭FileSystem组件对象endfunction服务器端脚本:/与数据库进行交互HTML页面编码:id=printname=print/调用打印函数INPUTtype=hiddenid=text1name=labelvalue=/保存服务器端传来的数据 添加评论15:49:09|固定链接 | 引用通告 (0) | 记录它 | WEB开发固定链接关闭/blog/cns!32F0FA0361376772!124.entry8月4日ASP.NET ASP.NET编程中的十大技巧 ASP.NET编程中的十大技巧在本篇文件中,我们将讨论编程人员在使用ASP.NET开发应用程序时需要注意的10个技巧,这些技巧涉及从缺省的控件、表单名的改变到StringBuilder类的使用,有助于编程人员能够尽快地适应.NET环境。 1、在使用Visual Studio .NET时,除直接或非引用的对象外,不要使用缺省的名字。 .NET带来的好处之一是所有的源代码和配置文件都是纯文本文件,能够使用Notepad或WordPad等任意的文本编辑器进行编辑。如果不愿意,我们并非一定要使用Visual Studio .NET作为集成开发环境。但使用了Visual Studio .NET,我们可以在Windows文件管理器中看到文件,或在Visual Studio .NET之外从文本编辑器中浏览文件的内容。 使用Visual Studio .NET作为集成开发环境有许多好处,其中最显著的好处是它极大地提高了生产效率。使用Visual Studio. NET,我们能够在付出较小代价的情况下更快地开发软件。作为集成开发环境一部分的IntelliSense提供自动的代码完成、在输入方法或函数时提供动态帮助、语法错误的实时提示,以及其他能够提高生产效率的功能。 象其他复杂的工具那样,在学会如何充分发挥它的作用和掌握其“习性”前,Visual Studio .NET也会使我们产生一种挫折感。有时,它象一个难以了解的黑盒子,会生成大量的文件和许多无用的代码。 Visual Studio .NET的一个功能是,无论是类、控件或表单中的对象,它都能够为新对象提供缺省名字。例如,如果我们
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论