<FONT size=2>asp.net(VB)中存储过程的使用方法(<FONT color=#008000>与直接执行SQL语句基本相同,不同之处在于红色字体部位</FONT>)</FONT></DIV>
<DIV><FONT color=#008000 size=2>'连接数据库(使用udl文件链接数据库)</FONT></DIV>
<DIV><FONT size=2>Dim DBPath as string = server.MapPath("condb.udl")<BR>Dim conn AS OleDBConnection = New OleDBConnection("File Name =" & DBPath)<BR>conn.Open()</FONT></DIV>
<DIV><FONT color=#008000 size=2></FONT> </DIV>
<DIV><FONT color=#008000 size=2>'存储过程名称:YW_HRHSXX_1</FONT></DIV>
<DIV><FONT size=2>Dim prostr As String = "YW_HRHSXX_1('2003','01',1,1,1,1,'2003-02-08','hddd','1','2','3','4','1','2','3','4','1','2')"</FONT></DIV>
<DIV><FONT color=#008000 size=2>
<DIV><FONT color=#008000 size=2>'定义执行对象</FONT></DIV></FONT></DIV>
<DIV><FONT size=2>Cmd = New OLEDBCommand(prostr, conn)</FONT></DIV>
<DIV><FONT color=#ff0000 size=2><FONT color=#008000>'设置执行语句类型为存储过程</FONT><BR></FONT><FONT color=#ff0000 size=2>Cmd.CommandType=CommandType.StoredProcedure</FONT></DIV>
<DIV><FONT size=2>
<DIV><FONT color=#008000 size=2>'执行存储过程</FONT></DIV></FONT></DIV>
<DIV><FONT size=2>Cmd.ExecuteNonQuery()</FONT></DIV>
<DIV><FONT size=2>Cmd.connection.close()</FONT></DIV>
<DIV><FONT size=2>conn.close()</FONT>
<DIV><FONT color=#008000 size=2>'连接数据库(使用udl文件链接数据库)</FONT></DIV>
<DIV><FONT size=2>Dim DBPath as string = server.MapPath("condb.udl")<BR>Dim conn AS OleDBConnection = New OleDBConnection("File Name =" & DBPath)<BR>conn.Open()</FONT></DIV>
<DIV><FONT color=#008000 size=2></FONT> </DIV>
<DIV><FONT color=#008000 size=2>'存储过程名称:YW_HRHSXX_1</FONT></DIV>
<DIV><FONT size=2>Dim prostr As String = "YW_HRHSXX_1('2003','01',1,1,1,1,'2003-02-08','hddd','1','2','3','4','1','2','3','4','1','2')"</FONT></DIV>
<DIV><FONT color=#008000 size=2>
<DIV><FONT color=#008000 size=2>'定义执行对象</FONT></DIV></FONT></DIV>
<DIV><FONT size=2>Cmd = New OLEDBCommand(prostr, conn)</FONT></DIV>
<DIV><FONT color=#ff0000 size=2><FONT color=#008000>'设置执行语句类型为存储过程</FONT><BR></FONT><FONT color=#ff0000 size=2>Cmd.CommandType=CommandType.StoredProcedure</FONT></DIV>
<DIV><FONT size=2>
<DIV><FONT color=#008000 size=2>'执行存储过程</FONT></DIV></FONT></DIV>
<DIV><FONT size=2>Cmd.ExecuteNonQuery()</FONT></DIV>
<DIV><FONT size=2>Cmd.connection.close()</FONT></DIV>
<DIV><FONT size=2>conn.close()</FONT>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货