Click here to Skip to main content
15,887,350 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionTrying to find the highest number in a field.... Pin
CCG327-Jul-07 9:14
CCG327-Jul-07 9:14 
AnswerRe: Trying to find the highest number in a field.... Pin
Christian Graus27-Jul-07 9:43
protectorChristian Graus27-Jul-07 9:43 
AnswerRe: Trying to find the highest number in a field.... Pin
Paul Conrad27-Jul-07 10:01
professionalPaul Conrad27-Jul-07 10:01 
AnswerRe: Trying to find the highest number in a field.... Pin
Naji El Kotob27-Jul-07 11:20
Naji El Kotob27-Jul-07 11:20 
QuestionError Message Pin
jds120727-Jul-07 7:31
jds120727-Jul-07 7:31 
AnswerRe: Error Message Pin
codemunkeh27-Jul-07 7:49
codemunkeh27-Jul-07 7:49 
AnswerRe: Error Message Pin
Paul Conrad27-Jul-07 8:28
professionalPaul Conrad27-Jul-07 8:28 
AnswerRe: Error Message Pin
Johan Hakkesteegt31-Jul-07 22:26
Johan Hakkesteegt31-Jul-07 22:26 
The error is thrown simply because nowhere in your code do you actually connect to the database.

jds1207 wrote:
cmd.Connection = con

You tell the DataAdapter to use this connection, but not to actually open it.

If you want you can try to adapt this function to your needs:
	Public Function OpenConnection(ByVal conn As SqlConnection, Optional ByVal db As String = "") As Boolean<br />
Try<br />
If conn.State = ConnectionState.Closed Then conn.Open()<br />
If conn.State = ConnectionState.Broken Then<br />
conn.Close()<br />
conn.Open()<br />
If db <> "" Then conn.ChangeDatabase(db)<br />
End If<br />
If conn.State <> ConnectionState.Open Then OpenConnection = False Else OpenConnection = True<br />
Catch Ex As Exception<br />
MsgBox(Ex.Message & "happened in: public function OpenConnection")<br />
End Try<br />
End Function


just call it before .Fill.

Good luck,

Johan

My advice is free, and you may get what you paid for.

QuestionImporting data into Sharepoint document libraries Pin
Potso27-Jul-07 7:19
Potso27-Jul-07 7:19 
QuestionHELP PLEASE. BASIC EXCEL TASKS Pin
frankiebaby227-Jul-07 6:07
frankiebaby227-Jul-07 6:07 
AnswerRe: HELP PLEASE. BASIC EXCEL TASKS Pin
frankiebaby227-Jul-07 8:57
frankiebaby227-Jul-07 8:57 
Questionprint the richtextbox text Pin
eyes200727-Jul-07 5:03
eyes200727-Jul-07 5:03 
AnswerRe: print the richtextbox text Pin
Paul Conrad29-Jul-07 6:16
professionalPaul Conrad29-Jul-07 6:16 
QuestionCRC 16 Pin
Cory Kimble27-Jul-07 3:46
Cory Kimble27-Jul-07 3:46 
AnswerRe: CRC 16 Pin
kubben27-Jul-07 5:24
kubben27-Jul-07 5:24 
GeneralRe: CRC 16 Pin
Cory Kimble27-Jul-07 6:43
Cory Kimble27-Jul-07 6:43 
GeneralRe: CRC 16 Pin
Luc Pattyn27-Jul-07 13:32
sitebuilderLuc Pattyn27-Jul-07 13:32 
GeneralRe: CRC 16 Pin
Cory Kimble30-Jul-07 7:03
Cory Kimble30-Jul-07 7:03 
GeneralRe: CRC 16 Pin
Luc Pattyn30-Jul-07 7:21
sitebuilderLuc Pattyn30-Jul-07 7:21 
Questionremove Icon from Form Pin
Rupesh Kumar Swami27-Jul-07 2:37
Rupesh Kumar Swami27-Jul-07 2:37 
AnswerRe: remove Icon from Form Pin
Tom Deketelaere27-Jul-07 2:46
professionalTom Deketelaere27-Jul-07 2:46 
QuestionWhy does my TabPage not show? Pin
Steven J Jowett27-Jul-07 1:42
Steven J Jowett27-Jul-07 1:42 
AnswerRe: Why does my TabPage not show? Pin
kubben27-Jul-07 1:55
kubben27-Jul-07 1:55 
GeneralRe: Why does my TabPage not show? Pin
Steven J Jowett27-Jul-07 2:24
Steven J Jowett27-Jul-07 2:24 
Questionhow can use VScrollBar to Scroll a long page.... Pin
fmlove27-Jul-07 1:28
fmlove27-Jul-07 1:28 

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.