Solved

objConnection.Open() error.  Trying to write record to sql database and get error message

Posted on 2004-09-03
2
726 Views
Last Modified: 2012-08-13
I am trying to save a record to my sql 2000 database and get the following error message.

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.


Here is my code that creates the error message.

'Write ELA Objective Info record
            Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=FBISK-TAKS;user id=sa;password=")
            Dim objCommand As SqlCommand = New SqlCommand
            objCommand.Connection = objConnection

            Dim r4 As Int16
            For r4 = 1 To 51
                objCommand.CommandText = "Insert Into itemAnalysisDetail " _
                            & "(admDate, studentId, teacherId, objectiveNumber, itemCorrectResp, studentResp) " & _
                            "VALUES(@admDate, @studentId, @teacherId, @readingElaobj(r4), @readingElaItemCorrectRespArray(r4), @readingElaStudentRespArray(r4))"
                objConnection.Open()      <<<<<--------------------------------RECEIVES the ERROR MESSAGE
                objCommand.ExecuteNonQuery()
                objConnection.Close()
            Next


Any help would be greatly appreciated.

Thanks
Kenny
0
Comment
Question by:kwh3856
2 Comments
 
LVL 8

Accepted Solution

by:
gregasm earned 500 total points
Comment Utility
wrap the code in a try catch block and then view the message property. This way you may get some insight into the problem.

try

'Write ELA Objective Info record
            Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=FBISK-TAKS;user id=sa;password=")
            Dim objCommand As SqlCommand = New SqlCommand
            objCommand.Connection = objConnection

            Dim r4 As Int16
            For r4 = 1 To 51
                objCommand.CommandText = "Insert Into itemAnalysisDetail " _
                            & "(admDate, studentId, teacherId, objectiveNumber, itemCorrectResp, studentResp) " & _
                            "VALUES(@admDate, @studentId, @teacherId, @readingElaobj(r4), @readingElaItemCorrectRespArray(r4), @readingElaStudentRespArray(r4))"
                objConnection.Open()      <<<<<--------------------------------RECEIVES the ERROR MESSAGE
                objCommand.ExecuteNonQuery()
                objConnection.Close()
            Next

catch ex as Exception
    msgbox(ex.message)


end try

What did the message say?
0
 

Author Comment

by:kwh3856
Comment Utility
Greg,
I had the wrong password to login to SQL...

Thanks
Kenny


P.S.
I have a new error if you would like to try on that one.  I will post it as a new question.

Thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now