ASP中使用SQL SERVER做查询 请知道的人解释下····急在线等····

来源:百度知道 编辑:UC知道 时间:2024/06/30 17:50:53
string sql = " select CustomerID,Password from M_PersonInfo ";
我这样做的··可是我不知道要不要想MyQL那样要写OPEN()
MySQL中要写
MyConnection.Open();
·
·
·
MySqlCommand cmd = new MySqlCommand(Sql, MyConnection);
//command.CommandText = Sql.ToString().Trim();
try
{
cmd.ExecuteNonQuery();

}
//catch(SqlException ex)
catch
{
MyConnection.Close();
//ex.Message.ToString();
}
finally
{
cmd.Dispose();
MyConnection.Close();
}
我不知道用SQL SERVER 也要写这些,
如果要的话请告诉我怎么写
Set

Connstr

是···

Set conn=Server.CreateObject("ADODB.Connection")
Connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath("db_DangJian.mdb")
conn.Open connstr

sql = ""
set rs = conn.execute(sql)

dim conn
Set conn = Server.Createobject("ADODB.Connection")
conn.Open "driver={SQL Server};server=服务器名;database=数据库名;uid=sa;pwd=密码"

sql = " select CustomerID,Password from M_PersonInfo "
Set rs=Server.Createobject("ADODB.Recordset")
rs.Open sql,conn,1,3
if rs.recordcount<>0 then
rs.movefirst
while not rs.bof and not rs.eof
response.write(rs("customerID"))
rs.movenext
wend
end if
rs.close
set rs =nothing
conn.close
set conn = nothing