Click here to Skip to main content
15,891,431 members
Home / Discussions / Database
   

Database

 
GeneralRe: Save Image in SQL Database Pin
bapu288928-Aug-08 5:37
bapu288928-Aug-08 5:37 
GeneralRe: Save Image in SQL Database Pin
Wendelius28-Aug-08 7:49
mentorWendelius28-Aug-08 7:49 
QuestionRe: Save Image in SQL Database Pin
bapu288928-Aug-08 7:59
bapu288928-Aug-08 7:59 
AnswerRe: Save Image in SQL Database Pin
Wendelius28-Aug-08 8:09
mentorWendelius28-Aug-08 8:09 
QuestionRe: Save Image in SQL Database Pin
bapu288928-Aug-08 8:18
bapu288928-Aug-08 8:18 
AnswerRe: Save Image in SQL Database Pin
Wendelius28-Aug-08 8:29
mentorWendelius28-Aug-08 8:29 
GeneralRe: Save Image in SQL Database Pin
bapu288928-Aug-08 8:38
bapu288928-Aug-08 8:38 
GeneralRe: Save Image in SQL Database Pin
Wendelius28-Aug-08 9:00
mentorWendelius28-Aug-08 9:00 
No problem,

Perhaps the easiest way is to make the connection static so that every time you connect to the database, you get the same connection. Something like (may contain errors):
Private Function GetDBConnection()        
   Static SqlConn = Nothing

   If SqlConn Is Nothing Then
      ' Compose the database file name.        
      ' Modify this if the database is somewhere else.        
      Dim DBname As String = Application.StartupPath()        
      DBname = DBname.Substring(0, DBname.LastIndexOf("\bin"))        
      DBname = DBname & "\Images.mdf"        
      ' Compose the connect string.         
      Dim connect_string As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=" & _        
      DBname & ";Integrated Security=True;User Instance=True"        
      ' Open a database connection.        
      SqlConn = New Data.SqlClient.SqlConnection(connect_string)        
      SqlConn.Open()        
   End If
   ' Return the connection.        
   Return SqlConn    
End Function


And when using this, don't close and don't dispose the connection, so comment the lines conImage.Close() and conImage.Dispose() in btnDelete_Click and LoadImages and btnSave_Click

The idea is to test that you are using the same database all the time. If this doesn't help then we change back to the original logic and try something else.
GeneralRe: Save Image in SQL Database Pin
bapu288928-Aug-08 9:19
bapu288928-Aug-08 9:19 
GeneralRe: Save Image in SQL Database Pin
Wendelius28-Aug-08 9:34
mentorWendelius28-Aug-08 9:34 
GeneralRe: Save Image in SQL Database Pin
bapu288928-Aug-08 9:48
bapu288928-Aug-08 9:48 
GeneralRe: Save Image in SQL Database Pin
Wendelius28-Aug-08 9:54
mentorWendelius28-Aug-08 9:54 
QuestionRe: Save Image in SQL Database Pin
bapu288928-Aug-08 23:23
bapu288928-Aug-08 23:23 
AnswerRe: Save Image in SQL Database Pin
Ashfield29-Aug-08 2:33
Ashfield29-Aug-08 2:33 
QuestionRe: Save Image in SQL Database Pin
bapu288929-Aug-08 2:54
bapu288929-Aug-08 2:54 
AnswerRe: Save Image in SQL Database Pin
Ashfield29-Aug-08 3:14
Ashfield29-Aug-08 3:14 
QuestionRe: Save Image in SQL Database Pin
bapu288929-Aug-08 4:13
bapu288929-Aug-08 4:13 
AnswerRe: Save Image in SQL Database Pin
Wendelius29-Aug-08 7:34
mentorWendelius29-Aug-08 7:34 
QuestionRe: Save Image in SQL Database Pin
bapu288929-Aug-08 7:57
bapu288929-Aug-08 7:57 
AnswerRe: Save Image in SQL Database Pin
Wendelius29-Aug-08 8:32
mentorWendelius29-Aug-08 8:32 
NewsRe: Save Image in SQL Database Pin
bapu288929-Aug-08 9:50
bapu288929-Aug-08 9:50 
GeneralRe: Save Image in SQL Database Pin
Wendelius29-Aug-08 10:17
mentorWendelius29-Aug-08 10:17 
NewsRe: Save Image in SQL Database Pin
bapu288929-Aug-08 10:57
bapu288929-Aug-08 10:57 
GeneralRe: Save Image in SQL Database Pin
Wendelius29-Aug-08 11:15
mentorWendelius29-Aug-08 11:15 
GeneralRe: Save Image in SQL Database Pin
bapu288929-Aug-08 11:25
bapu288929-Aug-08 11:25 

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.