国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP。NET連SQL7接口源代碼?

2024-05-04 11:06:28
字體:
來源:轉載
供稿:網友
the following example shows what a simple ado.net application that connects to the northwind database and returns a list of categories would look like. the example writes the output to the console, or command prompt.<br>
<br>
the following example shows what a simple ado.net application that connects to the northwind database and returns a list of categories. the example writes the output to the console, or command prompt.<br>
<br>
sqlclient<br>
[visual basic]<br>
imports system<br>
imports system.data<br>
imports system.data.sqlclient<br>
imports microsoft.visualbasic<br>
<br>
public class sample<br>
<br>
&nbsp;&nbsp;public shared sub main() <br>
&nbsp;&nbsp;&nbsp;&nbsp;dim nwindconn as sqlconnection = new sqlconnection(&quot;data source=localhost;&quot; & _<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;user id=sa;password=pwd;initial catalog=northwind&quot;)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;dim catcmd as sqlcommand = nwindconn.createcommand()<br>
&nbsp;&nbsp;&nbsp;&nbsp;catcmd.commandtext = &quot;select categoryid, categoryname from categories&quot;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;nwindconn.open()<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;dim myreader as sqldatareader = catcmd.executereader()<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;do while myreader.read()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.writeline(vbtab & &quot;{0}&quot; & vbtab & &quot;{1}&quot;, myreader.getint32(0), myreader.getstring(1))<br>
&nbsp;&nbsp;&nbsp;&nbsp;loop<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;myreader.close()<br>
&nbsp;&nbsp;&nbsp;&nbsp;nwindconn.close()<br>
&nbsp;&nbsp;end sub<br>
end class<br>
[c#]<br>
using system;<br>
using system.data;<br>
using system.data.sqlclient;<br>
<br>
class sample<br>
{<br>
&nbsp;&nbsp;public static void main() <br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;sqlconnection nwindconn = new sqlconnection(&quot;data source=localhost;user id=sa;password=pwd;initial catalog=northwind&quot;);<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;sqlcommand catcmd = nwindconn.createcommand();<br>
&nbsp;&nbsp;&nbsp;&nbsp;catcmd.commandtext = &quot;select categoryid, categoryname from categories&quot;;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;nwindconn.open();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;sqldatareader myreader = catcmd.executereader();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;while (myreader.read())<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.writeline(&quot;/t{0}/t{1}&quot;, myreader.getint32(0), myreader.getstring(1));<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;myreader.close();<br>
&nbsp;&nbsp;&nbsp;&nbsp;nwindconn.close();<br>
&nbsp;&nbsp;}<br>
}<br>
oledb<br>
[visual basic]<br>
imports system<br>
imports system.data<br>
imports system.data.oledb<br>
imports microsoft.visualbasic<br>
<br>
public class sample<br>
<br>
&nbsp;&nbsp;public shared sub main() <br>
&nbsp;&nbsp;&nbsp;&nbsp;dim nwindconn as oledbconnection = new oledbconnection(&quot;provider=sqloledb;data source=localhost;&quot; & _<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;user id=sa;password=pwd;initial catalog=northwind&quot;)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;dim catcmd as oledbcommand = nwindconn.createcommand()<br>
&nbsp;&nbsp;&nbsp;&nbsp;catcmd.commandtext = &quot;select categoryid, categoryname from categories&quot;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;nwindconn.open()<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;dim myreader as oledbdatareader = catcmd.executereader()<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;do while myreader.read()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.writeline(vbtab & &quot;{0}&quot; & vbtab & &quot;{1}&quot;, myreader.getint32(0), myreader.getstring(1))<br>
&nbsp;&nbsp;&nbsp;&nbsp;loop<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;myreader.close()<br>
&nbsp;&nbsp;&nbsp;&nbsp;nwindconn.close()<br>
&nbsp;&nbsp;end sub<br>
end class<br>
[c#]<br>
using system;<br>
using system.data;<br>
using system.data.oledb;<br>
<br>
class sample<br>
{<br>
&nbsp;&nbsp;public static void main() <br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;oledbconnection nwindconn = new oledbconnection(&quot;provider=sqloledb;data source=localhost;user id=sa;password=pwd;initial catalog=northwind&quot;);<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;oledbcommand catcmd = nwindconn.createcommand();<br>
&nbsp;&nbsp;&nbsp;&nbsp;catcmd.commandtext = &quot;select categoryid, categoryname from categories&quot;;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;nwindconn.open();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;oledbdatareader myreader = catcmd.executereader();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;while (myreader.read())<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.writeline(&quot;/t{0}/t{1}&quot;, myreader.getint32(0), myreader.getstring(1));<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;myreader.close();<br>
&nbsp;&nbsp;&nbsp;&nbsp;nwindconn.close();<br>
&nbsp;&nbsp;}<br>
}<br>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 铜鼓县| 炎陵县| 防城港市| 临沂市| 浑源县| 泾源县| 屯门区| 临朐县| 长丰县| 襄垣县| 浮梁县| 九台市| 西林县| 溧水县| 夹江县| 玉溪市| 祁东县| 石阡县| 绥芬河市| 房山区| 多伦县| 仪征市| 淮北市| 平果县| 荆门市| 繁昌县| 育儿| 丹凤县| 五华县| 黄浦区| 布尔津县| 阿坝县| 通河县| 兴文县| 承德县| 翁源县| 阆中市| 湖州市| 神池县| 和硕县| 台江县|