0

can any one help me about this error

Private Sub BtnSave_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
        If Objconnection.State = ConnectionState.Closed Then
            Try

            Catch ex As Exception

            End Try
            Objconnection.Open()---->>> The ConnectionString property has not been initialized.


            

        End If

        Objcmmand = New SqlCommand(" Insert into cases_of_accidents ( IdVehicle , VehicleName ) values (" & VehicleType_Id.Text & "," & VehicleType_name.Text & ")", Objconnection)
        iresult = Objcommand.ExecuteNonQuuery()
        If iresult > 0 Then
            MessageBox(" Record inserted successfully "

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Zeth643
0

Its really simple, the exception tells you everything.

Before you can open a connection you need to assign the route of the connection string to the database.

i.e.

Objconnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;"
Objconnection.Open()
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.