“The ConnectionString property has not been initialized” error in VB.NET

喜欢而已 提交于 2019-11-29 11:35:29

You never assigned your connection string to the connection object, just like the error is saying.

Insert a line setting the connection string before con.open.

Con.connectionstring = connection
Con.Open()

Or better yet, change your using statement as follows

Dim Connection As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=G:\VB Project\Library Catalog System\Library Catalog System\library.mdf;Integrated
Security=True;Connect Timeout=30;User Instance=True"

Using Con As New SqlConnection(connection)

You are creating the connection string object but never assigning it to your SqlCommand object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!