Click here to Skip to main content
15,867,488 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerMessage Removed Pin
13-Jul-20 11:39
professionaljkirkerx13-Jul-20 11:39 
Questionpls help Pin
Member 148797912-Jul-20 21:44
Member 148797912-Jul-20 21:44 
SuggestionRe: pls help Pin
Richard MacCutchan2-Jul-20 21:48
mveRichard MacCutchan2-Jul-20 21:48 
GeneralRe: pls help Pin
ZurdoDev6-Jul-20 8:10
professionalZurdoDev6-Jul-20 8:10 
AnswerRe: pls help Pin
David Mujica6-Jul-20 7:27
David Mujica6-Jul-20 7:27 
JokeRe: pls help Pin
DerekT-P7-Jul-20 2:18
professionalDerekT-P7-Jul-20 2:18 
QuestionAngular service error http 400 using .Net core api to accept json, escaped quotes crashing api Pin
jkirkerx29-Jun-20 12:48
professionaljkirkerx29-Jun-20 12:48 
AnswerRe: Angular service error http 400 using .Net core api to accept json, escaped quotes crashing api Pin
Richard Deeming29-Jun-20 23:42
mveRichard Deeming29-Jun-20 23:42 
GeneralRe: Angular service error http 400 using .Net core api to accept json, escaped quotes crashing api Pin
jkirkerx30-Jun-20 6:06
professionaljkirkerx30-Jun-20 6:06 
Questionerror server Pin
Member 1265427722-Jun-20 2:37
Member 1265427722-Jun-20 2:37 
AnswerRe: error server Pin
ZurdoDev22-Jun-20 2:44
professionalZurdoDev22-Jun-20 2:44 
AnswerRe: error server Pin
Richard Deeming22-Jun-20 5:19
mveRichard Deeming22-Jun-20 5:19 
GeneralRe: error server Pin
Member 1265427722-Jun-20 23:37
Member 1265427722-Jun-20 23:37 
AnswerRe: error server Pin
Member 1265427722-Jun-20 23:41
Member 1265427722-Jun-20 23:41 
AnswerRe: error server Pin
OriginalGriff22-Jun-20 23:51
mveOriginalGriff22-Jun-20 23:51 
GeneralRe: error server Pin
Member 1265427723-Jun-20 1:34
Member 1265427723-Jun-20 1:34 
AnswerRe: error server Pin
OriginalGriff22-Jun-20 23:43
mveOriginalGriff22-Jun-20 23:43 
Read the error message - it's pretty explicit.

The OdbcConnection object is not open.

That means that you have created an instance, and either tried to open it but the operation failed (and you swallowed the exception), you didn't try to open it, or you opened it then subsequently closed it again.

Without your code, there isn't a lot we can add to that...

Your code should look something like this:
C#
using (OdbcConnection con = new OdbcConnection(strConnect))
    {
    con.Open();
    using (OdbcCommand cmd = new OdbcCommand("SELECT Age, Description FROM myTable WHERE ID = @ID", con))
        {
        cmd.Parameters.AddWithValue("@ID", myTextBox.Text);
        using (OdbcDataReader reader = cmd.ExecuteReader())
            {
            while (reader.Read())
                {
                int age = (int) reader["Age"];
                string desc = (string) reader["Description"];
                Console.WriteLine($"{age}\n{desc}");
                }
            }
        }
    }

"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!

QuestionAnother NetCore question Pin
pkfox31-May-20 4:58
professionalpkfox31-May-20 4:58 
AnswerRe: Another NetCore question Pin
Mycroft Holmes31-May-20 12:22
professionalMycroft Holmes31-May-20 12:22 
GeneralRe: Another NetCore question Pin
pkfox1-Jun-20 1:58
professionalpkfox1-Jun-20 1:58 
GeneralRe: Another NetCore question Pin
Mycroft Holmes1-Jun-20 12:44
professionalMycroft Holmes1-Jun-20 12:44 
AnswerRe: Another NetCore question Pin
Richard Deeming1-Jun-20 3:31
mveRichard Deeming1-Jun-20 3:31 
GeneralRe: Another NetCore question Pin
pkfox1-Jun-20 4:08
professionalpkfox1-Jun-20 4:08 
AnswerRe: Another NetCore question Pin
jkirkerx1-Jun-20 13:47
professionaljkirkerx1-Jun-20 13:47 
GeneralRe: Another NetCore question Pin
pkfox4-Jun-20 10:54
professionalpkfox4-Jun-20 10:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.