Click here to Skip to main content
15,881,173 members
Home / Discussions / C#
   

C#

 
GeneralRe: Socket Pin
mrithula81-Mar-09 18:48
mrithula81-Mar-09 18:48 
QuestionHow to Copy Form in Project ? Pin
E_Gold28-Feb-09 20:12
E_Gold28-Feb-09 20:12 
AnswerRe: How to Copy Form in Project ? Pin
Yusuf28-Feb-09 21:26
Yusuf28-Feb-09 21:26 
GeneralRe: How to Copy Form in Project ? Pin
E_Gold28-Feb-09 22:13
E_Gold28-Feb-09 22:13 
GeneralRe: How to Copy Form in Project ? Pin
Yusuf1-Mar-09 3:28
Yusuf1-Mar-09 3:28 
AnswerRe: How to Copy Form in Project ? Pin
Henry Minute1-Mar-09 1:51
Henry Minute1-Mar-09 1:51 
QuestionAccess Database crashing on load in Vista Pin
Hitchic0528-Feb-09 17:22
Hitchic0528-Feb-09 17:22 
AnswerRe: Access Database crashing on load in Vista [modified] Pin
Douglas Troy1-Mar-09 7:18
Douglas Troy1-Mar-09 7:18 
First off, you really need to get yourself a good C# book and do some reading, because you have some serious fundamental flaws in your code. The Database connection State is an Enumerated type (see example usage[^]), you need not cast it to a String and then compare, you should be comparing the Enumerated types. Additionally, you should really make use of Using[^] statements in your code, it will make for cleaner code, and will ensure the objects are probably closed and disposed.

I see one potential problem, in that you're creating an instance of a SQLCommand using a connection object that might be null; and to top it off, you're doing that outside the scope of your Try/Catch block.

See this line: System.Data.OleDb.OleDbCommand SQLCommand = new System.Data.OleDb.OleDbCommand(sSQLStatement, DBConnection);

If you're not sure if the connection has been created and opened, then you should do that first. Once you have a valid connection, THEN create your SQL Command and hook that up to the connection and execute your query (see Example[^] on MSDN)

But seriously, go read about Enumerated types and Using statements, and hopefully this will help you over come your problem.






Last modified: 13mins after originally posted --



AnswerRe: Access Database crashing on load in Vista Pin
Razvan Dimescu1-Mar-09 22:42
Razvan Dimescu1-Mar-09 22:42 
GeneralRe: Access Database crashing on load in Vista Pin
Douglas Troy2-Mar-09 7:18
Douglas Troy2-Mar-09 7:18 
QuestionMonitor and scan internet files Pin
Ghaith Hachem28-Feb-09 12:09
Ghaith Hachem28-Feb-09 12:09 
AnswerRe: Monitor and scan internet files Pin
abdul jalil1-Mar-09 3:48
abdul jalil1-Mar-09 3:48 
GeneralRe: Monitor and scan internet files Pin
Ghaith Hachem1-Mar-09 4:04
Ghaith Hachem1-Mar-09 4:04 
QuestionReading specif Excel sheet headers Pin
alvas8928-Feb-09 11:09
alvas8928-Feb-09 11:09 
AnswerRe: Reading specif Excel sheet headers Pin
Calin Tatar28-Feb-09 16:12
Calin Tatar28-Feb-09 16:12 
GeneralRe: Reading specif Excel sheet headers Pin
alvas893-Mar-09 9:08
alvas893-Mar-09 9:08 
AnswerRe: Reading specif Excel sheet headers Pin
0x3c01-Mar-09 0:03
0x3c01-Mar-09 0:03 
GeneralRe: Reading specif Excel sheet headers Pin
alvas893-Mar-09 9:12
alvas893-Mar-09 9:12 
QuestionCD Image in C# [modified] Pin
Demasoni28-Feb-09 9:54
Demasoni28-Feb-09 9:54 
AnswerRe: CD Image in C# Pin
harold aptroot28-Feb-09 10:41
harold aptroot28-Feb-09 10:41 
AnswerRe: CD Image in C# Pin
Henry Minute1-Mar-09 2:01
Henry Minute1-Mar-09 2:01 
QuestionTo display Node atrributes such that node name is added to tree? Pin
rasingh128-Feb-09 8:23
rasingh128-Feb-09 8:23 
Questionwindows version check Pin
shabya28-Feb-09 7:26
shabya28-Feb-09 7:26 
AnswerRe: windows version check Pin
harold aptroot28-Feb-09 7:30
harold aptroot28-Feb-09 7:30 
GeneralRe: windows version check Pin
0x3c028-Feb-09 8:15
0x3c028-Feb-09 8:15 

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.