Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 17-Jul-18 17:54pm

1 solution

You don't need
VB
else if
and you have no
VB
end if
And there is no member
VB
connection.state.open
in System.Data.SqlClient. Also, your sub is named
VB
open()
so presumably you want to end up with an open connection. This might get you where you want to go:
VB
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900