[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-09-03
2
Medium Priority
?
735 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
gregasm earned 2000 total points
ID: 11973078
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
ID: 11973269
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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 …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

649 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