未处理的异常发生system.data.dll添加关键字不受支持 [英] Unhandled exception occured system.data.dll addition keyword not supported

查看:72
本文介绍了未处理的异常发生system.data.dll添加关键字不受支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行该程序,但是此消息弹出未处理的异常发生的系统.data.dll添加关键字不支持



在visual basic中。 />


我尝试过:



Imports System.data.sqlclient



模块dbConnector

public conn as new sqlconnection

public sub open()

如果conn.state = connection.state.open那么

conn.close()



否则如果

with conn

.connectionstring =HOME-PC\SQLEXPRESS; database = AMS; user id = admin; password = ITadmin101

。打开()



结束

end sub

结束模块

i tried to run the program but this message pop up "unhandled exception occured system.data.dll addition keyword not supported"

in visual basic.

What I have tried:

Imports System.data.sqlclient

module dbConnector
public conn as new sqlconnection
public sub open()
if conn.state = connection.state.open then
conn.close()

else if
with conn
.connectionstring = "HOME-PC\SQLEXPRESS; database=AMS; user id = admin; password = ITadmin101"
.Open()

end with
end sub
end module

推荐答案

您不需要
else if

你没有

end if

并且System.Data.SqlClient中没有成员

And there is no member

connection.state.open

。此外,您的子名称为

open()

,因此您可能希望以开放式连接结束。这可能会让你到达目的地:

so presumably you want to end up with an open connection. This might get you where you want to go:

Imports System.Data.SqlClient

Module dbConnector
    Public conn As New SqlConnection

    Public Sub open()
        If conn.State <> ConnectionState.Open Then
            With conn
                .ConnectionString = "HOME-PC\SQLEXPRESS; database=AMS; user id = admin; password = ITadmin101"
                .Open()
            End With
        End If
    End Sub
End Module


这篇关于未处理的异常发生system.data.dll添加关键字不受支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆