主题:我这段数据库代码连接不上,请问高手如何解决?
<%@ Page Language=“VB”ContentType="text/html"Debug="true"%>
<%@ Import Namespace="System.Data.sqlClient"%>
<%@ Import Namespace="System.Data"%>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="学生基本信息.aspx.vb" Inherits="WebApplication1.学生基本信息"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>学生基本信息</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<script language="vb" runat="serve">
dim StuSql as string
Function MakeSelectSql()as string
dim SqlStr as string
if Trim(编号.Text)<>""then
SqlStr="where 编号like '%"+Trim(编号.Text)+"%"
else
SqlStr+="where 编号 like'%"
end if
if Trim(编号.Text)<>""then
SqlStr+="and 编号like '%"+Trim(姓名.Text)+"%"
end if
if Trim(籍贯.Text)<>""then
SqlStr+="and 编号like '%"+Trim(籍贯.Text)+"%"
end if
MakeSelectSql=SqlStr
End Function
Sub BindGrid()
dim SqlConn as new sqlConnedtion()
dim SqlConn as new sqlCommand()
dim SqIDs as new DataSet()
dim SqlAdp as new sqlDataAdaper()
dim ConnStr as string
ConnStr="Server=COMPUTER;Database=谢庄实验室管理;UID=sa;PWD=;"
SqlConn.ConnectionString=ConnStr
SqlConn.Open()
SqlCmd.Connection=SqlConn
StuSql=MakeSelectSql()
SqlCmd.CommandText="Select学生姓名 as 编号,姓名,性别,籍贯,毕业论文
from 学生基本信息,学生学习情况”
SqlAdp.SelectCommd=SqlCmd
SqlAdp.fill(SqlIDs,"学生基本信息")
StuDataGrid.Datasource=SqlDs.Tables"学生基本信息".defaultview
StuDataGrid.DataBind()
SqlComm.Close()
End Sub
Sub page_load(sender as Object,e as eventArgs)
if Not IsPostBack then
StuSql=""
BindGrid()
End if
End Sub
Sub AtPageIndexChanged(sender as Object,e as DataGridPageChangedEventArgs)
StuSql=MakeSelectSql()
StuDataGrid.CurrentPageIndex=e.NewPageIndex
BindGrid()
End Sub
Sub SearchStu(sender as Object,e as EventArgs)
StuDataGrid.CurrentPageIndex=0
StuSql=MakeSelectSql()
BindGrid()
End Sub
</script>
<style type="text/css">
.style1 { FONT-SIZE: 24px; FONT-FAMILY: "楷体_GB2312" }
.style2 { COLOR: #0000ff }
</style>
</HEAD>
<%@ Import Namespace="System.Data.sqlClient"%>
<%@ Import Namespace="System.Data"%>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="学生基本信息.aspx.vb" Inherits="WebApplication1.学生基本信息"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>学生基本信息</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<script language="vb" runat="serve">
dim StuSql as string
Function MakeSelectSql()as string
dim SqlStr as string
if Trim(编号.Text)<>""then
SqlStr="where 编号like '%"+Trim(编号.Text)+"%"
else
SqlStr+="where 编号 like'%"
end if
if Trim(编号.Text)<>""then
SqlStr+="and 编号like '%"+Trim(姓名.Text)+"%"
end if
if Trim(籍贯.Text)<>""then
SqlStr+="and 编号like '%"+Trim(籍贯.Text)+"%"
end if
MakeSelectSql=SqlStr
End Function
Sub BindGrid()
dim SqlConn as new sqlConnedtion()
dim SqlConn as new sqlCommand()
dim SqIDs as new DataSet()
dim SqlAdp as new sqlDataAdaper()
dim ConnStr as string
ConnStr="Server=COMPUTER;Database=谢庄实验室管理;UID=sa;PWD=;"
SqlConn.ConnectionString=ConnStr
SqlConn.Open()
SqlCmd.Connection=SqlConn
StuSql=MakeSelectSql()
SqlCmd.CommandText="Select学生姓名 as 编号,姓名,性别,籍贯,毕业论文
from 学生基本信息,学生学习情况”
SqlAdp.SelectCommd=SqlCmd
SqlAdp.fill(SqlIDs,"学生基本信息")
StuDataGrid.Datasource=SqlDs.Tables"学生基本信息".defaultview
StuDataGrid.DataBind()
SqlComm.Close()
End Sub
Sub page_load(sender as Object,e as eventArgs)
if Not IsPostBack then
StuSql=""
BindGrid()
End if
End Sub
Sub AtPageIndexChanged(sender as Object,e as DataGridPageChangedEventArgs)
StuSql=MakeSelectSql()
StuDataGrid.CurrentPageIndex=e.NewPageIndex
BindGrid()
End Sub
Sub SearchStu(sender as Object,e as EventArgs)
StuDataGrid.CurrentPageIndex=0
StuSql=MakeSelectSql()
BindGrid()
End Sub
</script>
<style type="text/css">
.style1 { FONT-SIZE: 24px; FONT-FAMILY: "楷体_GB2312" }
.style2 { COLOR: #0000ff }
</style>
</HEAD>