日期:2014-05-17  浏览次数:20829 次

数据库链接
完成了ODBC   DSN的设置,同时也完成了与SQL   Server的联机测试。但是,这仅限于与SQL   Server的联机测试、登录帐号检查而已。实际上,对于SQL   Server内的数据库是否拥有操作权限,是否允许记录的读取写入等,到目前为止尚未得知,哪位高人可以给我一段代码可以看到数据库中某个表的字段名称

------解决方案--------------------
<!--#include file= "../share.asp "-->
<%
dim bm,lj,xsbj,xslj
bm=request( "bm ")
lj=request( "lj ")
xsbj=request( "bja ")
xslj=request( "lja ")

%>

<HTML>
<HEAD>
<link REL= "stylesheet " TYPE= "text/css " HREF= " <%=Session( "ThemePath ")%> /CSS/Share.CSS ">
<link REL= "stylesheet " TYPE= "text/css " HREF= " <%=Session( "ThemePath ")%> /CSS/repeater.CSS ">
<script language= "JScript.Encode " src= " <%=Session( "ThemePath ")%> /Script/function.JS "> </script>
<script language= "javascript ">

function check()
{
showSending( '正在对所有数据进行核查导入,请稍候... ');

document.form1.onsubmit = ' ';
document.form1.submit();
}
</script>
</HEAD>
<body leftMargin= "0 " topMargin= "0 " MARGINHEIGHT= "0 " MARGINWIDTH= "0 ">
<%=strGetHeadbox(tmpTitle & "在校学生基本信息导入 ")%>
<%



'得到SQLSERVER的字段名

Set Rs=server.CreateObject( "adodb.recordset ")
Rs.Open "select top 1 id from sysobjects where xtype= 'u ' and name= 'school_pupilinfo ' ", Conn, 1, 1
If Not Rs.EOF Then
Set Reco=server.CreateObject( "adodb.recordset ")
Set Reco = Conn.Execute( "select name from syscolumns where id= " & Rs( "id ") & " ORDER BY colid ")
Do While Not Reco.EOF
if lcase(reco( "Name ")) <> "classid " and lcase(reco( "name ")) <> "id " and lcase(reco( "name ")) <> "stu_image " and lcase(reco( "Name ")) <> "status " then
end if
Reco.MoveNext
Loop
Reco.Close
End If


'用二维数组把SQLSERVER里的字段装起来
dim myarray()

ReDim myarray(2,0)

Set Rs1=server.CreateObject( "adodb.recordset ")
Rs1.Open "select top 1 id from sysobjects where xtype= 'u ' and name= 'school_pupilinfo ' ", Conn, 1, 1
If Not Rs1.EOF Then

Set Rs_sql=server.CreateObject( "adodb.recordset ")
Set Rs_sql = Conn.Execute( "select name from syscolumns where id= " & Rs( "id ") & " ORDER BY colid ")

Do While Not Rs_sql.EOF
if lcase(Rs_sql( "Name ")) <> "classid " and lcase(rs_sql( "name ")) <> "id " and lcase(rs_sql( "name ")) <> "stu_image " and lcase(Rs_sql( "Name ")) <> "status " then

ReDim Preserve myarray(2,ubound(myarray,2)+1)

myarray(1,ubound(myarray,2)) = GetDatabaseFieldDescribing(Conn, "school_pupilinfo ",Rs_sql( "Name "))
myarray(2,ubound(myarray,2)) = "F_ " & Rs_sql( "Name ")

end if
Rs_sql.MoveNext

loop
end if


'得到用户表的字段名
dim kzm
kzm = lcase(mid(lj,InstrRev(lj, ". ")+1))
set excelconn = server.createobject( "adodb.connection ")
if ucase(kzm)= &qu