如图所示,在安全性-登陆里可以看到右边列表里的用户,选中用户右键-属性可以更改用户密码,及数据库角色等。
查看用户名,及密码是否正确,可以单独登陆 查询分析器
如果能登陆说明设置正确,在mssql搭建的asp cms里经常要用到用户名,密码。
现在看每个数据下面的用户选项,如图
选中一个一个数据库,或下面的用户选项可以 “新建数据库用户”
要注意的是登陆名必须在 "安全性-登陆"里有,并且,不能用默认的登录名,如sa ......
/// <summary>
/// 创建数据库。
/// </summary>
/// <param name="srvName">表示要连接的服务器名</param>
/// <param name="dbName">指定要创建的数据库名</param>
private string CreateDB(string srvName, string dbName)
{
SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass();
SQLDMO.SQLServer srv = new SQLDMO.SQLServerClass();
srv.Connect(srvName, "sa", "");
&nb ......
/// <summary>
/// 创建数据库。
/// </summary>
/// <param name="srvName">表示要连接的服务器名</param>
/// <param name="dbName">指定要创建的数据库名</param>
private string CreateDB(string srvName, string dbName)
{
SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass();
SQLDMO.SQLServer srv = new SQLDMO.SQLServerClass();
srv.Connect(srvName, "sa", "");
&nb ......
public sealed class DbOper
{
///<summary>
/// DbOper类的构造函数
///</summary>
private DbOper()
{
}
///<summary>
/// 数据库备份
///</summary>
public static void DbBackup()
{
SQLDMO.Backup oBackup = new SQLDMO.BackupClass();
SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
try
{
oSQLServer.LoginSecure = false;
&nb ......
public sealed class DbOper
{
///<summary>
/// DbOper类的构造函数
///</summary>
private DbOper()
{
}
///<summary>
/// 数据库备份
///</summary>
public static void DbBackup()
{
SQLDMO.Backup oBackup = new SQLDMO.BackupClass();
SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
try
{
oSQLServer.LoginSecure = false;
&nb ......
SQL SERVER 和EXCEL的数据导入导出
1、在SQL SERVER里查询Excel数据:
-- ======================================================
SELECT *
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
下面是个查询的示例,它通过用于 Jet 的 OLE DB 提供程序查询 Excel 电子表格。
SELECT *
from OpenDataSource ( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...xactions
-------------------------------------------------------------------------------------------------
2、将Excel的数据导入SQL server :
-- ======================================================
SELECT * into newtable
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
实例:
SELECT * into newtable
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Sourc ......
asp衔接Mssql的办法及常见的差错
//第一种写法:
MM_conn_STRING = "Driver={SQL Server};server=(local);uid=sa;pwd=;database=infs;"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING
SET RS=SERVER.CreateObject("ADOBD.recordset")
SQL="SELECT * from TABLE ORDER BY ID DESC"
RS.open SQL,CONN,3,3
//第二种写法:(DSN衔接)
MM_conn_STRING="DSN=BBS;UID=SA;PWD=12345"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING
SET RS=SERVER.CreateObject("ADOBD.recordset")
SQL="SELECT * from TABLE ORDER BY ID DESC"
RS.open SQL,CONN,3,3 // 3,3是改动、删除、增添开关!
//第三种写法:
MM_conn_STRING_own = "Driver={SQL Server};server=(local);uid=sa;pwd=11111;database=infs;"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING_own
//第四种 - 这种方式用在ACCESS中
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" _
& Server.MapPath("asp.mdb")
set conn = server.createobject("adodb.connection")
co ......
asp衔接Mssql的办法及常见的差错
//第一种写法:
MM_conn_STRING = "Driver={SQL Server};server=(local);uid=sa;pwd=;database=infs;"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING
SET RS=SERVER.CreateObject("ADOBD.recordset")
SQL="SELECT * from TABLE ORDER BY ID DESC"
RS.open SQL,CONN,3,3
//第二种写法:(DSN衔接)
MM_conn_STRING="DSN=BBS;UID=SA;PWD=12345"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING
SET RS=SERVER.CreateObject("ADOBD.recordset")
SQL="SELECT * from TABLE ORDER BY ID DESC"
RS.open SQL,CONN,3,3 // 3,3是改动、删除、增添开关!
//第三种写法:
MM_conn_STRING_own = "Driver={SQL Server};server=(local);uid=sa;pwd=11111;database=infs;"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING_own
//第四种 - 这种方式用在ACCESS中
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" _
& Server.MapPath("asp.mdb")
set conn = server.createobject("adodb.connection")
co ......
1、SQL2000中一表有一日期型字段BirthDay,记录出生日期,想每年在本日生日前15天,将其过滤出来,怎么写Where条件?:
select out_date from sales_out_head_tab where (DATEDIFF(day,DATEADD(year ,year(getdate())-year(out_date) ,out_date )
,getdate()) BETWEEN -15 and 0 ) order by out_date ......