在本地安装好.Net FrameworkSD。
test.vb
Imports System Imports System.IO Imports System.Data Imports System.Data.SqlClient Imports System.Configuration Namespace myNamespace |
这是一个连接数据库的Class,这样每次调用只要写:
Dim myConnection As SqlConnection
myConnection = myClass1.DatabaseConnection
数据库的登陆信息都写在网站根目录下的 web.config,然后用就写ConfigurationSettings.AppSettings("SQLConnectionString")),因为ConfigurationSettings属于System.Configuration所以要写Import。附上web.config:
<configuration> <system.web> <customErrors mode="Off" /> <compilation debug="true" /> </system.web> <appSettings> <add key="SQLConnectionString" value="server=servername;uid=username;pwd=password;database=databasename" /> </appSettings> </configuration> |
打开DOS,写入 vbc /r:system.data.dll /r:system.dll /t:library /out:z:/bin/
test.dll z:/bin/test.vb 把编译后的test.dll放到bin目录下。(/r:是调用其他的dll, /t:是说明要生成dll, /out:是放置的目录, 最后是源文件)
Imports System Imports System.IO Imports System.Data Imports System.Data.SqlClient Imports System.Configuration Namespace myNamespace |
这是一个连接数据库的Class,这样每次调用只要写:
Dim myConnection As SqlConnection
myConnection = myClass1.DatabaseConnection
数据库的登陆信息都写在网站根目录下的 web.config,然后用就写ConfigurationSettings.AppSettings("SQLConnectionString")),因为ConfigurationSettings属于System.Configuration所以要写Import。附上web.config:
<configuration> <system.web> <customErrors mode="Off" /> <compilation debug="true" /> </system.web> <appSettings> <add key="SQLConnectionString" value="server=servername;uid=username;pwd=password;database=databasename" /> </appSettings> </configuration> |
打开DOS,写入 vbc /r:system.data.dll /r:system.dll /t:library /out:z:/bin/
test.dll z:/bin/test.vb 把编译后的test.dll放到bin目录下。(/r:是调用其他的dll, /t:是说明要生成dll, /out:是放置的目录, 最后是源文件)
Imports System Imports System.IO Imports System.Data Imports System.Data.SqlClient Imports System.Configuration Namespace myNamespace |
这是一个连接数据库的Class,这样每次调用只要写:
Dim myConnection As SqlConnection
myConnection = myClass1.DatabaseConnection
数据库的登陆信息都写在网站根目录下的 web.config,然后用就写ConfigurationSettings.AppSettings("SQLConnectionString")),因为ConfigurationSettings属于System.Configuration所以要写Import。附上web.config:
<configuration> <system.web> <customErrors mode="Off" /> <compilation debug="true" /> </system.web> <appSettings> <add key="SQLConnectionString" value="server=servername;uid=username;pwd=password;database=databasename" /> </appSettings> </configuration> |
打开DOS,写入 vbc /r:system.data.dll /r:system.dll /t:library /out:z:/bin/
test.dll z:/bin/test.vb 把编译后的test.dll放到bin目录下。(/r:是调用其他的dll, /t:是说明要生成dll, /out:是放置的目录, 最后是源文件)
testdll.aspx 完整调用
<%@ Import Namespace="myNamespace" %> <script language="vb" runat="server"> <html> <body> |