ScottGu's Blog - ASP.NET MVC 3_ Razor’s @_ and _text_ syntax.pdf


'Knowledge' 카테고리의 다른 글

[스크랩] base64 인코딩 & 디코딩 원리  (0) 2018.05.23
[C#][LowCode] Base64 Encoder/Decoder in C#  (0) 2018.05.23
Hashtable foreach  (0) 2018.05.17
서브도메인과 블로그 연동하기  (0) 2018.05.06
[리눅스] 스크린 명령어  (0) 2018.05.01





그림 그리는 개발자 __ 메모리 덤프(Memory dump) 분석하기 2.pdf

그림 그리는 개발자 __ 메모리 덤프(Memory dump) 분석하기 1.pdf


출처: http://imagej.tistory.com/153




[Qt5] 32비트에서 64비트로 프로젝트 변경하기 - 나긋한 개발.pdf




링크: http://ssscool.tistory.com/entry/C-Hashtable-foreach


foreach (DictionaryEntry entry in ht)

TextBox1.AppendText( "키 : " + entry.Key + " 값 : " + entry.Value );










제목: Microsoft SQL Server Management Studio

------------------------------


서버 '[컴퓨터 이름]'에 대한 데이터베이스 연결이(가) 실패했습니다.  (Microsoft.SqlServer.Smo)


도움말을 보려면 다음을 클릭하십시오: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600.1+((KJ_RTM).100402-1539+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=데이터베이스+연결+Server&LinkId=20476


------------------------------

추가 정보:


Transact-SQL 문 또는 일괄 처리를 실행하는 동안 예외가 발생했습니다. (Microsoft.SqlServer.ConnectionInfo)


------------------------------


데이터베이스 '[DB명]'은(는) 해당 버전이 706이므로 열 수 없습니다. 이 서버는 버전 661 및 이전 버전을 지원합니다. 다운그레이드 경로는 지원되지 않습니다.

새 데이터베이스 '[DB명]'을(를) 열 수 없습니다. CREATE DATABASE가 중단됩니다. (Microsoft SQL Server, 오류: 948)


도움말을 보려면 다음을 클릭하십시오: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=948&LinkId=20476


------------------------------



서버쪽은 64비트 SQL Server 2012 R2 가 설치되어 있고 프로그램에서 MST 라는 DB를 생성하여 데이터 압축 후 SQL Express 2008 사용하는 PC 에서 DB 연결하려고 할때 


"데이터베이스 'MST'은(는) 해당 버전이 706이므로 열 수 없습니다. 이 서버는 버전 661 및 이전 버전을 지원합니다. 다운그레이드 경로는 지원되지 않습니다."


이라고 PC 쪽에서 에러가 발생됩니다.

DB Compatibility Level 이 문제라고 하여 90으로 호환성을 낮추어도 위와 같습니다.

다른 어떤 문제가 있을까요??


 

 

댓글
2016.11.25 10:36:13 (*.6.129.207)
[레벨:37]Terry

말 그대로 DB 자체가 지원이 안되는겁니다.

상위호환이 안되는거죠..^^;;


2가지중 편하신걸로 처리하시면 될듯..


1안) SQL EXPRESS 2008 -> SQL EXPRESS 2012 로 변경

2안) SQL 2012 R2 의 DB -> 스크립트로 EXPORT 하여 , SQL 2008 SSMS에서 해당스크립트 실행


2안의 경우

하기 링크 참고하세요..


http://www.sqler.com/index.php?mid=bSQLQA&search_target=comment_userid&search_keyword=chy18&document_srl=851611


수고하세요~


사용 하면는 Const 문을 상수를 선언 하 고 해당 값을 설정 합니다. 상수를 선언 하 여 값으로 의미 있는 이름을 할당 합니다. 상수 선언 되 면 수정 또는 새 값을 지정할 수 없습니다.

프로시저 내에서 또는 모듈, 클래스 또는 구조체의 선언 섹션에는 상수를 선언합니다. 클래스 또는 구조 수준 상수는 Private 기본적으로도로 선언할 수 있지만 PublicFriendProtected, 또는 Protected Friend 적절 한 수준의 코드 액세스에 대 한 합니다.

올바른 심볼 이름을 (규칙은 변수 이름 만들기와 동일)와 숫자 또는 문자열 상수 및 연산자 (함수 호출 없음)의 구성 된 식의 상수 있어야 합니다.

참고

일부 Visual Studio 사용자 인터페이스 요소의 경우 다음 지침에 설명된 것과 다른 이름 또는 위치가 시스템에 표시될 수 있습니다. 이러한 요소는 사용하는 Visual Studio 버전 및 설정에 따라 결정됩니다. 자세한 내용은 IDE 개인 설정을 참조하세요.

상수 선언 하려면

  • 액세스 지정자를 포함 하는 선언을 작성 된 Const 키워드 및 다음 예와 같이 식:

    VB
    Public Const DaysInYear = 365
    Private Const WorkDays = 250
    

     Option Infer  Off  Option Strict  On, 데이터 형식을 지정 하 여 명시적으로 상수를 선언 해야 합니다 (Boolean, Byte, Char, DateTime, Decimal, Double, Integer, Long, Short, Single, 또는 String).

     Option Infer  On 또는 Option Strict  Off, 데이터 형식으로 지정 하지 않고 상수를 선언할 수 있습니다는 As 절. 컴파일러에는 상수 식의 형식에서의 유형을 결정합니다. 자세한 내용은 참조 상수 및 리터럴 데이터 형식합니다.

으로 명시적으로 지정된 하는 데이터 형식이 지정 된 상수를 선언 하려면

  • 포함 하는 선언을 작성는 As 키워드 및 명시적 데이터 형식, 다음 예제와 같이:

    VB
    Public Const MyInteger As Integer = 42
    Private Const DaysInWeek As Short = 7
    Protected Friend Const Funday As String = "Sunday"
    

    코드 줄에 하나씩 단일 상수만 선언 하는 경우 더 쉽게 읽을 수는 있지만 한 줄에 여러 개의 상수를 선언할 수 있습니다. 한 줄에 여러 개의 상수를 선언 하는 경우 이들은 모두 가져야 동일한 액세스 레벨 (Public, Private, Friend, Protected, 또는 Protected Friend).

한 줄에 여러 개의 상수를 선언 하려면

  • 다음 예제와 같이 공백, 쉼표와 선언을 구분 합니다.

    Public Const Four As Integer = 4, Five As Integer = 5, Six As Integer = 44  


'Knowledge > Visual Basic 6+' 카테고리의 다른 글

VB6 단축키  (0) 2018.04.19
[VB6] 전역변수 선언 (Not Global keyword)  (0) 2018.04.02
[VB6] Replace Function - Visual Basic 6.0  (0) 2018.04.02
Visual Basic 문법  (0) 2018.03.27
[VB6] What is Me.Caption  (0) 2018.03.26



깃허브페이지, 티스토리, 네이버 블로그 서브도메인 연결하기 __ Ari's Github Blog.pdf




I'm using System.Data.SQLite provider in an ASP.NET application (framework 4.0). The issue I'm running into is that when I INSERT something in a table in the SQLite database, the database gets locked and the lock isn't being released even after the connection is disposed.

When trying to access the file, the error is: "The process cannot access the file 'catalog.sqlite' because it is being used by another process."

My code is pretty straightforward, I open the connection, read some data from a SQLServer database, insert that data into SQLite (through SQLiteDataAdapter) and then close the connection and dispose everything just to be on the safe side. But still, I get that error when I try to zip the file after it's being populated with the data.

I've read all kind of suggestions here on StackOverflow but none of them has helped solving the problem (turning off the antivirus, changing the transaction model, waiting a few seconds before zipping up the file, wrapping all the insert calls into a transaction, etc.. but none has helped solving this issue.

Maybe there's something specific to ASP.NET (multithreading being the issue? Even though I'm testing it on a development machine where there's only one call to that function and no concurrency?)

As a side note, I tried avoiding DataTable and SQLiteDataAdapter and using only SQLiteCommand directly and that way it works a charm. Of course I can keep building my queries as strings instead of using the data adapters, but I kind of find it a bit awkward when there's a framework built to do that.

    I had the same problem using the datasets/tableadapters generated with the designer shipped with System.Data.Sqlite.dll version 1.0.82.0 -- after closing the connection we were unable to read the database file using System.IO.FileStream. I was disposing correctly both connection and tableadapters and I was not using connection pooling.

    According to my first searches (for example this and this thread) that seemed a problem in the library itself -- either objects not correctly released and/or pooling issues (which I don't use).

    After reading your question I tried to replicate the problem using only SQLiteCommand objects and I found that the problem arises when you don't dispose them. Update 2012-11-27 19:37 UTC: this is further confirmed by this ticket for System.Data.SQLite, in which a developer explains that "allSQLiteCommand and SQLiteDataReader objects associated with the connection [should be] properly disposed".

    I then turned back on the generated TableAdapters and I saw that there was no implementation of the Dispose method -- so in fact the created commands were not disposed. I implemented it, taking care of disposing all the commands, and I have got no problem.

    Here's the code in C#, hope this helps. Please note that the code is converted from the original in Visual Basic, so expect some conversion errors.

    //In Table Adapter    
    protected override void Dispose(bool disposing)
    {
       base.Dispose(disposing);
    
        Common.DisposeTableAdapter(disposing, _adapter, _commandCollection);
    }
    
    public static class Common
    {
        /// <summary>
        /// Disposes a TableAdapter generated by SQLite Designer
        /// </summary>
        /// <param name="disposing"></param>
        /// <param name="adapter"></param>
        /// <param name="commandCollection"></param>
        /// <remarks>You must dispose all the command,
        /// otherwise the file remains locked and cannot be accessed
        /// (for example, for reading or deletion)</remarks>
        public static void DisposeTableAdapter(
            bool disposing,
            System.Data.SQLite.SQLiteDataAdapter adapter,
            IEnumerable<System.Data.SQLite.SQLiteCommand> commandCollection)
        {
            if (disposing) {
                DisposeSQLiteTableAdapter(adapter);
    
                foreach (object currentCommand_loopVariable in commandCollection)
                {
                    currentCommand = currentCommand_loopVariable;
                    currentCommand.Dispose();
                }
            }
        }
    
        public static void DisposeSQLiteTableAdapter(
                System.Data.SQLite.SQLiteDataAdapter adapter)
        {
            if (adapter != null) {
                DisposeSQLiteTableAdapterCommands(adapter);
    
                adapter.Dispose();
            }
        }
    
        public static void DisposeSQLiteTableAdapterCommands(
                System.Data.SQLite.SQLiteDataAdapter adapter)
        {
            foreach (object currentCommand_loopVariable in {
                adapter.UpdateCommand,
                adapter.InsertCommand,
                adapter.DeleteCommand,
                adapter.SelectCommand})
            {
                currentCommand = currentCommand_loopVariable;
                if (currentCommand != null) {
                    currentCommand.Dispose();
                }
            }
        }
    }

    Update 2013-07-05 17:36 UTC gorogm's answer highlights two important things:

    • according to the changelog on the official site of System.Data.SQLite, starting from version 1.0.84.0 the above code should not be needed, since the library takes care of this. I haven't tested this, but in the worst case you only need this snippet:

      //In Table Adapter    
      protected override void Dispose(bool disposing)
      {
        base.Dispose(disposing);
      
        this.Adapter.Dispose();
      }
    • about the implementation of the Dispose call of the TableAdapter: it is is better to put this in a partial class, so that a dataset regeneration does not affected this code (and any additional code you may need to add).

      I have the same problem. My scenario was after getting the data inside SQLite Database file I want to delete that file but it always throw an error "...using by other process". Even I dispose the SqliteConnection or SqliteCommand the error still occur. I've fixed the error by calling GC.Collect().

      Code snippet

      public void DisposeSQLite()
      {
          SQLiteConnection.Dispose();
          SQLiteCommand.Dispose();
      
          GC.Collect();
      }

      Hope this help.

        In my case I was creating SQLiteCommand objects without explicitly disposing them.

        var command = connection.CreateCommand();
        command.CommandText = commandText;
        value = command.ExecuteScalar();

        I wrapped my command in a using statement and it fixed my issue.

        static public class SqliteExtensions
        {
            public static object ExecuteScalar(this SQLiteConnection connection, string commandText)
            {
                // Added using
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = commandText;
                    return command.ExecuteScalar();
                }
            }
        }

        Then you can use it like this

        connection.ExecuteScalar(commandText);

          The following worked for me:  MySQLiteConnection.Close(); SQLite.SQLiteConnection.ClearAllPools()

          I found edymtt's answer right about blaming TableAdapters / Datasets, but instead of modifying the every time re-generated TableAdapter codefile, I found an other solution: to manually call .Dispose on the TableAdapter's child elements. (In .NET 4.5, latest SQLite 1.0.86)

          using (var db = new testDataSet())
          {
              using (testDataSetTableAdapters.UsersTableAdapter t = new testDataSetTableAdapters.UsersTableAdapter())
              {
                  t.Fill(db.Users);
                  //One of the following two is enough
                  t.Connection.Dispose(); //THIS OR
                  t.Adapter.Dispose();    //THIS LINE MAKES THE DB FREE
              }
              Console.WriteLine((from x in db.Users select x.Username).Count());
          }

            In most cases the problem will arise if you don't dispose your readers and commands properly. There is a scenario in which commands and readers will not dispose properly.

            Scenario 1: In case you are running a boolean function. before a result is reached the code in the finally block will not excecute. This is a big problem if you are going to be evaluating the results of function isDataExists while executing code if it suits the result i.e

                if(isDataExists){
                    // execute some code
                }

            The function being evaluated

                public bool isDataExists(string sql)
                {
                    try
                    {
                        OpenConnection();
                        SQLiteCommand cmd = new SQLiteCommand(sql, connection);
                        reader = cmd.ExecuteReader();
                        if (reader != null && reader.Read())
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception expMsg)
                    {
                        //Exception
                    }
                    finally
                    {
                        if (reader != null)
                        {
                            reader.Dispose();
                        }
                        CloseConnection();
                    }
                    return true;
                }

            Solution: Dispose your reader and command inside the try block as follows

                        OpenConnection();
                        SQLiteCommand cmd = new SQLiteCommand(sql, connection);
                        reader = cmd.ExecuteReader();
                        if (reader != null && reader.Read())
                        {
                            cmd.Dispose();
                            CloseConnection();
                            return true;
                        }
                        else
                        {
                            cmd.Dispose();
                            CloseConnection();
                            return false;
                        }

            Finally dispose the reader and command just in case some thing went wrong

                    finally
                    {
                        if (reader != null)
                        {
                            reader.Dispose();
                        }
                        CloseConnection();
                    }

              As said earlier SQLite objects must be destroyed. However, there is a strange behavior: connection must be open during a call Dispose on commands. For example:

              using(var connection = new SqliteConnection("source.db"))
              {
                  connection.Open();
                  using(var command = connection.CreateCommand("select..."))
                  {
                      command.Execute...
                  }
              }

              works fine, but:

              using(var connection = new SqliteConnection("source.db"))
              {
                  connection.Open();
                  using(var command = connection.CreateCommand("select..."))
                  {
                      command.Execute...
                      connection.Close();
                  }
              }

              gives the same file lock

              This was one of the top google results I had found when I ran into this error. However, none of the responses helped me so after more searching around and googling I came up with this code that works from some of the code from http://www.tsjensen.com/blog/post/2012/11/10/SQLite-on-Visual-Studio-with-NuGet-and-Easy-Instructions.aspx

              However, I did not have to use the NuGet at all. What my program does is downloads a db file from a server every time it is opened. Then if a user updates that db, it will be uploaded for everyone to get the next time they open the same program. I was getting the error that the file was in use after updating the local file and trying to upload it to our SharePoint. Now it works fine.

              Public Function sqLiteGetDataTable(sql As String) As DataTable
                  Dim dt As New DataTable()
                  Using cnn = New SQLiteConnection(dbConnection)
                      cnn.Open()
                      Using cmd As SQLiteCommand = cnn.CreateCommand()
                          cmd.CommandText = sql
                          Using reader As System.Data.SQLite.SQLiteDataReader = cmd.ExecuteReader()
                              dt.Load(reader)
                              reader.Dispose()
                          End Using
                          cmd.Dispose()
                      End Using
                      If cnn.State <> System.Data.ConnectionState.Closed Then
                          cnn.Close()
                      End If
                      cnn.Dispose()
                  End Using
                  Return dt
              End Function

              Ensuring that any IDisposable (e.g., SQLiteConnection, SQLiteCommand, etc) is properly disposed of solves this problem. I should re-iterate that one must be using "using" as a habit to ensure proper disposing of disposable resources.

              I had the same problem and it was only fixed by disposing the DbCommand in the using statement, but with Pooling = true my problem was fixed!!

                              SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder
                              {
                                  Pooling = true
                              };


              + Recent posts