Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7434713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:56:21+00:00 2026-05-29T09:56:21+00:00

Every time I tried to connect to the database it give me this error

  • 0

Every time I tried to connect to the database it give me this error “The ConnectionString property has not been initialized”

what can I do to solve this?

here are my codes

Module Module1
    Function GetInfoForStudent(ByRef QueryName As String, ByVal UserName As String, ByVal Password As String) As DataTable
        Using Con As New SqlConnection
            Try
                Using OleCon As New SqlConnection
                    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"
                    Con.Open()
                    Dim Cmd As SqlCommand = Con.CreateCommand()
                    Cmd.CommandType = CommandType.StoredProcedure
                    Cmd.CommandText = QueryName
                    Cmd.Parameters.AddWithValue("@user", UserName)
                    Cmd.Parameters.AddWithValue("@pass", Password)
                    Dim da As New SqlDataAdapter(Cmd)
                    Dim ds As New DataTable()
                    da.Fill(ds)
                    Return ds
                End Using
            Catch ex As Exception

                Throw New Exception(ex.Message)
            End Try
        End Using

    End Function

End Module

Sub ShowStudentInfo()
    Dim dt As DataTable = GetInfoForStudent("MyStoredProcName", "@user", "@pass")
    ' Since (presumably) only one is returned
    With dt.Rows(0)
        ' Assign your text boxes 
        StudentIDTextBox.Text = .Item("StudentID")
        LoginIDTextBox.Text = .Item("LoginID")
        Student_NameTextBox.Text = .Item("Student Name")
        Student_addressTextBox.Text = .Item("Student address")

    End With
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:56:22+00:00Added an answer on May 29, 2026 at 9:56 am

    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)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried decoding this base64 string so many times but every time i get
Every time I create an object that has a collection property I go back
I have tried contacting tech support with this question, but it has been over
I've tried to connect to my local machine every time I try and run
I've tried to connect to my local machine every time I try and run
Every time I call this method my NSMutableData is leaking and I cannot figure
I tried to submit my app thrice,every time it just failed,mailing me the same
Why does every time I do mvn jetty:run, maven tries to download some dependencies
Every time I turn on my company-owned development machine, I have to kill 10+
Every time I create a new project I copy the last project's ant file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.