首页 > 编程 > .NET > 正文

初学VB.NET连接SQL数据库!

2024-07-10 13:00:53
字体:
来源:转载
供稿:网友
<%@ page language="vb" debug="true" trace="true" %>
<%@ import namespace="system.data" %>
<%@ import namespace="system.data.sqlclient" %>
<script language="vb" runat="server">
sub page_load(sender as object, e as eventargs)
dim ds as dataset
dim myconnection as sqlconnection
dim myadpt as sqldataadapter
myconnection =new sqlconnection("server='localhost';uid=sa;pwd=wenasen.com; database=credit_sql")
myadpt = new sqldataadapter("select * from admin",myconnection)
ds= new dataset()
myadpt.fill(ds,"admin")
dga.datasource=ds.tables("admin").defaultview
dga.databind()
end sub
</script>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>显示sql数据库</title>
</head>
<body>
<form id="form1" runat="server">
<asp:datagrid id="dga" runat="server" allowpaging="true" width="100%" cellpadding="1" edititemstyle-backcolor=""
headerstyle-backcolor="#00cccc" border="1" alternatingitemstyle-backcolor="#cccccc"
></asp:datagrid>
</form>
</body>
</html>

商业源码热门下载www.html.org.cn

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表