----testdll.aspx<%@ Page explicit="true" %>
<script language="VB" runat="Server">
[System.Runtime.InteropServices.DllImport("ADODB.dll"]
'这个就是引用dll,不知这样写对不对,但出错,提示需要标识符。 Dim temp1 As Object
Dim DBConn As ADODB.Connection DBConn = New ADODB.Connection
DBConn.Open("DRIVER={SQL Server};Server=bby;Database=OAT;UID=sa;PWD=")
Session("DBConn") = DBConn temp1 = Session("DBConn").Execute("SELECT UserName FROM User_Info WHERE UserID=001")
If Not temp1.EOF Then
Session("UserName") = temp1(0)
Response.Write("-----0-------)" +temp1(0))
End If
temp1.Close()
</script>
<script language="VB" runat="Server">
[System.Runtime.InteropServices.DllImport("ADODB.dll"]
'这个就是引用dll,不知这样写对不对,但出错,提示需要标识符。 Dim temp1 As Object
Dim DBConn As ADODB.Connection DBConn = New ADODB.Connection
DBConn.Open("DRIVER={SQL Server};Server=bby;Database=OAT;UID=sa;PWD=")
Session("DBConn") = DBConn temp1 = Session("DBConn").Execute("SELECT UserName FROM User_Info WHERE UserID=001")
If Not temp1.EOF Then
Session("UserName") = temp1(0)
Response.Write("-----0-------)" +temp1(0))
End If
temp1.Close()
</script>
解决方案 »
- 关于存储过程的参数传递问题
- post的数据是:Content-Type: multipart/form-data; 程序如何实现编码
- treeview 如何逐层加载?
- 请教关于SQL中如何把同一字段中相同内容的排在一起
- 怎么把Gridview的值赋给DropDownList
- There is no row at position 0各位师傅,请指点!
- 忙了一天还没解决,高手过来瞧瞧
- 自定义控件的怪问题
- 我在ASP.net中做了一个附件上传的功能,我把上传的文件写到C:\Inetpub\wwwroot\这个目录下,提示错误?不可写?
- 关于ASP网页注册,求大神帮忙!!
- 纪念江八点十周年
- ASP.net中操作Word的问题___很奇怪也
时间引用时实例化一下就可以啦。上面是c#的,VB的我没有用过,应该也一样吧
Imports System.Runtime.InteropServices
Public Class demo
<DllImport("user32.dll")> Function CopyFile(ByVal address As String, ByVal username As String, ByVal password As String, ByVal localfn As String, ByVal remotefn As String) As Integer
End Function
End Class
应用
Dim demoClass As demo = New demo
demoClass.CopyFile("1", "2", "3", "4", "5")
Imports System.Runtime.InteropServices
Public Class demo
<DllImport("user32.dll")> Shared Function CopyFile(ByVal address As String, ByVal username As String, ByVal password As String, ByVal localfn As String, ByVal remotefn As String) As Integer
End Function
End Class
应用
Dim demoClass As demo = New demo
demoClass.CopyFile("1", "2", "3", "4", "5")
'这个就是引用dll,不知这样写对不对,但出错,提示需要标识符。
这个是调用非托管代码的dll。
Imports System.Runtime.InteropServices<DllImport("user32.dll")>跟静态函数(类函数)
2,NEW 一个实例,对实例进行操作。
这是com组件(c++),能注册,把引用到项目里。
然后NEW 一个实例,对实例进行操作。
调用里一个方法是出现:System.Runtime.InteropServices.COMException: java.lang.NullPointerException
为什么?????
但这样调用感觉是不是好多限制了。比如我这个DLL中的类只是对初始化一些数据,根本不用返回值。
照你这样就引用就不行了,对不对啊。