• 全部
  • VBS
  • .NET技术
  • VBA
  • VB网络编程
  • VB多媒体
  • VB数据库
  • VB控件
  • VB COM/DCOM
  • VB基础类
  • VB API
  • 问答

Com+高手请进

wqjch 2005-03-05 01:52:09
我用RegSvcs注册Com+时出现以下错误:
Warning:the class ‘SampleOrderCom.RuleAutoGen’ has no class interface,which means that unmanaged late bound calls cannot take advantage of AutoComplete methods,

RuleAutoGen类的代码如下:

Imports System.EnterpriseServices
Imports System.Data.SqlClient


<Transaction(TransactionOption.Required)> Public Class RuleAutoGen
Inherits ServicedComponent

Private Conn As SqlConnection
Private Cmd As SqlCommand
Private myReader As SqlDataReader
Private variable_value As String
Private running_num As Int32
Private new_running_num As Integer
Private autoGenNum As String
Private years As String
Private YearReader As SqlDataReader
Private desc As String

<AutoComplete> Public Function updateNum(ByVal vVariable As String, _
ByVal vDepartment As String, ByVal vDivision As String, Optional ByVal vNum As Integer = 1) As String

autoGenNum = "-1"

Conn = Connection.ConnectionFactory()
Try
Dim sqlYears As String = "select substring(cast(year(getdate()) as varchar (4)),3,2) as years"

Dim CmdYears As New SqlCommand(sqlYears, Conn)

Dim sqlString As String = _
"SELECT variable_value, variable_running_num,description FROM m_system_variable" & _
" WHERE variable = @variable" & _
" AND department = @department" & _
" AND division = @division"
Cmd = New SqlCommand(sqlString, Conn)
'Cmd.ExecuteNonQuery()

Dim parmVariable As SqlParameter
parmVariable = Cmd.Parameters.Add("@variable", SqlDbType.Char, 25)
parmVariable.Direction = ParameterDirection.Input
parmVariable.Value = vVariable

Dim parmDepartment As SqlParameter
parmDepartment = Cmd.Parameters.Add("@department", SqlDbType.Char, 10)
parmDepartment.Direction = ParameterDirection.Input
parmDepartment.Value = vDepartment

Dim parmDivision As SqlParameter

parmDivision = Cmd.Parameters.Add("@division", SqlDbType.Char, 8)
parmDivision.Direction = ParameterDirection.Input
parmDivision.Value = vDivision

myReader = Cmd.ExecuteReader

If (myReader.Read()) Then
variable_value = myReader.GetString(0)
running_num = myReader.GetInt32(1)
desc = myReader.GetString(2)
End If
myReader.Close()

YearReader = CmdYears.ExecuteReader
If YearReader.Read() Then
years = YearReader.GetString(0)
End If
YearReader.Close()

Select Case running_num
Case 1 To 9
autoGenNum = variable_value & "-" & years & "-" & "000" & running_num
Case 10 To 99
autoGenNum = variable_value & "-" & years & "-" & "00" & running_num
Case 100 To 999
autoGenNum = variable_value & "-" & years & "-" & "0" & running_num
Case 1000 To 9999
autoGenNum = variable_value & "-" & years & "-" & running_num
Case Else
autoGenNum = "-1" 'Error No.
End Select

new_running_num = running_num + vNum

If new_running_num <= 10000 Then
sqlString = "UPDATE m_system_variable SET variable_running_num = " & _
"@running_num WHERE variable = @variable" & _
" AND department = @department" & _
" AND division = @division"
Cmd.CommandText = sqlString

Dim parmRunningNum As SqlParameter
parmRunningNum = Cmd.Parameters.Add("@running_num", SqlDbType.Int, 4)
parmRunningNum.Direction = ParameterDirection.Input
parmRunningNum.Value = new_running_num

Cmd.ExecuteNonQuery()
End If

Conn.Close()

Catch e As Exception
'Console.WriteLine(e)
Throw e

Finally
If Not (Conn Is Nothing) Then
Conn.Close()
End If
End Try

Return autoGenNum
End Function

End Class

我感觉就是因为用了<AutoComplete>这个我特性后出错,我应该怎么修改,谢谢!!!
...全文
73 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wqjch 2005-03-08
加上属性:ClassInterface(ClassInterfaceType.None)
和Imports System.Runtime.InteropServices
加在哪啊
回复
wqjch 2005-03-08
加上属性:ClassInterface(ClassInterfaceType.None)
和Imports System.Runtime.InteropServices
加在上啊
回复
xiaolang88 2005-03-06
加上属性:ClassInterface(ClassInterfaceType.None)
和Imports System.Runtime.InteropServices

回复
hamadou 2005-03-05
虽然不会,帮你up!
回复
发帖
VB
创建于2007-09-28

1.6w+

社区成员

VB技术相关讨论,主要为经典vb,即VB6.0
申请成为版主
帖子事件
创建了帖子
2005-03-05 01:52
社区公告
暂无公告