易截截图软件、单文件、免安装、纯绿色、仅160KB

C#连接Access和SQL Server数据库

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Str
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
/*
* connect to Sql Server
*/
string strConnection = "Data Source=ZRQ-PC;";
strConnection+="Initial Catalog=master;Integrated Security=True";
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open();
objConnection.Close();
/**************************************************************/
/*
* connect to access table
*/
//string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
//strConnection += @"Data Source=C:\Users\ZRQ\Documents\STU.accdb";
//OleDbConnection objConnection = new OleDbConnection(strConnection);
//objConnection.Open();
//objConnection.Close();
/**************************************************************/
/*
*as for connect to Oracle or MySql 等我学了再说吧……(*^__^*)
*/
}
}
}
其中的简易办法:
在“服务器资源管理器”中选择要连接的数据,then看它的属性中Name,copy to strConnection 即可~


相关文档:

C#在64位操作系统上连接Oracle的问题和解决方案


C#使用System.Data.OracleClient连接Oracle数据库。之前在WinXP上正常运行的程序移植到 Windows 2008 x64上之后就连不上数据库了,错误信息如下:
尝试加载 Oracle客户端库时引发BadImageFomatException。如果在安装32位Oracle客户端组件的情况下以64位模式运行,将出现此问题。
错误原因是原来WinXP机子上所安装的Orac ......

操作数据库结构的常用Sql命令(2)

操作数据库结构的常用Sql
下面是Sql Server 和 Access 操作数据库结构的常用Sql,内容由海娃整理,不正确与不完整之处还请提出,谢谢。
新建表:
create table [表名]
(
[自动编号字段] int IDENTITY (1,1)  PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] dateti ......

DBF表与SQL Server表的导入、导出

----------Dbf 导入 Sql Server表----------
以下均以SQL2000、VFP6及以上的表为例
代码导入:查询分析器中执行如下语句(先选择对应的数据库)
-------------如果接受导入数据的SQL表已存在
--如果接受导入数据的SQL表已经存在
Insert Into 已经存在的SQL表名 Select * from openrowset('MSDASQL','Driver=Microso ......

magento 在Magento中获取SQL语句

       Magento是在Zend Framework的基础上搭建而来,有两种方式可以从Magento的collection获得真正的SQL语句。
以 Mage::getResourceModel('reports/product_collection') 为例:
1
         $collection=Mage::getResourceModel('reports/product_collection'); ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号