如何将数据库和c#连接起来

[复制链接]
查看11 | 回复4 | 2011-11-10 13:22:52 | 显示全部楼层 |阅读模式
'1 连接数据库(使用命令)
Dim conStr As String = ConfigurationManager.ConnectionStrings("conStr").ConnectionString
'Dim conStr As String = "Data Source=.;Initial Catalog=Hotel;Persist Security Info=True;User ID=sa;Password=123456"
Dim con As SqlConnection = New SqlConnection(conStr)
Dim sql ...
回复

使用道具 举报

千问 | 2011-11-10 13:22:52 | 显示全部楼层
需要把你的数据文件(自定义.mdf)从SQL中分离,然后复制到C#项目对应的文件夹里然后开启SQL SERVERusing System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using...
回复

使用道具 举报

千问 | 2011-11-10 13:22:52 | 显示全部楼层
using (SqlConnection conn = new SqlConnection("Server=;Database=;Uid=;Pwd="))
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "";...
回复

使用道具 举报

千问 | 2011-11-10 13:22:52 | 显示全部楼层
新建一个数据库连接...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行