It’s me

June 25, 2009

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

Filed under: SQL SERVER — Tags: , — rothmans @ 3:16 pm

Visual Studio 2008과 Visual Studio 2008 Express Edition을 사용하고, ASP.NET의 App_Data 에 MDF 파일을 사용하려고 할때 다음과 같은 에러 메시지가 발생하는 경우가 있습니다

“사용자 인스턴스의 프로세스를 시작하지 못했기 때문에 SQL Server의 사용자 인스턴스를 생성하지 못했습니다. 연결이 닫힙니다.”

“Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.”

web.config 내용

<add name=”ConnectionString” connectionString=”Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDB.mdf;Integrated Security=True;User Instance=True” providerName=”System.Data.SqlClient”/>
 

해결방법
다음 폴더를 삭제합니다. 삭제 후 재시도 하면 폴더가 재생성되고 MDF 파일 및 로그등이 생성됩니다

C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS

April 29, 2009

Previous releases of Microsoft Visual Studio 2008

Filed under: SQL SERVER — rothmans @ 1:54 pm

Microsoft SQL 2008을 설치할 때 다음과 같이 Visual Studio 2008 SP1 을 요구하는 메시지가 표시됩니다.

규칙 “Microsoft Visual Studio 2008의 이전 릴리스 확인”
이 컴퓨터에 Microsoft Visual Studio 2008의 이전 릴리스가 설치되어 있습니다. SQL Server 2008을 설치하기 전에 Microsoft Visual Studio 2008을 SP1으로 업그레이드하십시오.

Rule “Previous releases of Microsoft Visual Studio 2008″ failed.
A previous release of Microsoft Visual Studio 2008 is installed on this computer. Upgrade Microsoft Visual Studio 2008 to the SP1 before installing SQL Server 2008.

Visual Studio 2008 SP1 이 설치되어 있어야 하나, 다음과 같은 방법으로 설치가 가능합니다.

Setup /ACTION=install /SkipRules=VSShellInstalledRule RebootRequiredCheck

이 방법은 문서화되어 있지는 않지만, VSShellInstalledRule 을 체크하는 부분을 Skip 함으로써 설치가 가능하게 합니다

April 8, 2009

IDE 상태에서 실행중인지 확인

Filed under: Visual Basic — Tags: — rothmans @ 1:32 pm

첫번째 방법)

Option Explicit

Private Sub Form_Load()
   Debug.Print RunningIDE
End Sub

Private Function RunningIDE() As Boolean
    Debug.Assert Not TestIDE(RunningIDE)
End Function

Private Function TestIDE(Test As Boolean) As Boolean
    Test = True
End Function

두번째 방법)

Public Function RunningCompiledCode() As Boolean
   On Error Resume Next
   Debug.Print 1 / 0
   RunningCompiledCode = (Err.Number = 0)
   Err.Clear
End Function

March 18, 2009

마지막 글자 제거

Filed under: C# — rothmans @ 1:57 pm

str.Substring(0, str.Length - 1);

February 25, 2009

SELECT * INTO {TARGET} FROM {SOURCE}

Filed under: SQL SERVER — rothmans @ 1:29 pm

- 새로운 테이블 생성, 전체 컬럼 INSERT
SELECT * INTO {TARGET} FROM {SOURCE}

- 새로운 테이블 생성, 일부 컬럼 INSERT
SELECT * INTO {TARGET}
  FROM (
                  SELECT COLUMN1, COLUMN2 FROM {SOURCE}
                ) AS TMP_TBL

- 기존 테이블 이용, 전체 컬럼 INSERT
INSERT INTO {TARGET} SELECT * FROM {SOURCE}

- 기존 테이블 이용, 일부 컬럼 INSERT
INSERT INTO {TARGET} SELECT COLUMN1, COLUMN2 FROM {SOURCE}

December 9, 2008

지정한 기간내의 일자 목록

Filed under: SQL SERVER — rothmans @ 5:35 pm

declare @todate varchar(10)
declare @frdate varchar(10)
declare @cudate varchar(10)
declare @dtdiff int
declare @cnt int

if object_id (’tempdb..#tempx’) is not null drop table #tempx
create table #tempx (idx int identity (1,1), cudate varchar(10))

set @frdate = ‘2008-12-30′
set @todate = ‘2009-01-02′
set @cnt = 0
set @dtdiff = datediff(day, convert(datetime, @frdate), convert(datetime, @todate))

while @cnt <= @dtdiff
begin
set @cudate = convert(varchar(10), dateadd(day, @cnt, convert(datetime, @frdate)), 120)
insert into #tempx (cudate) values (@cudate)
set @cnt = @cnt + 1
end

select * from #tempx

간단한 임시 테이블 사용 Stored procedure

Filed under: SQL SERVER — Tags: , , , — rothmans @ 10:45 am

create procedure temporay_table_test
as
begin
declare @frdate datetime
declare @cnt int
create table #tempx (idx int identity (1,1), frdate datetime)

set @cnt = 1
while @cnt < 5
begin
waitfor delay ‘00:00:01′ — 시간 delay
set @frdate = getdate()
set @cnt = @cnt + 1
insert into #tempx (frdate) values (@frdate)
end
select * from #tempx
end

if object_id (’tempdb..#tempx’) is not null drop table #tempx

October 2, 2008

UTF-8 UTF-16

Filed under: Javascript — rothmans @ 2:15 pm

 
/* utf.js – UTF-8 <=> UTF-16 convertion
*
* Copyright (C) 1999 Masanao Izumo <mo@goice.co.jp>
* Version: 1.0
* LastModified: Dec 25 1999
* This library is free.  You can redistribute it and/or modify it.
*/

/*
* Interfaces:
* utf8 = utf16to8(utf16);
* utf16 = utf16to8(utf8);
*/

function utf16to8(str) {
    var out, i, len, c;

    out = “”;
    len = str.length;
    for(i = 0; i < len; i++) {
c = str.charCodeAt(i);
if ((c >= 0×0001) && (c <= 0×007F)) {
    out += str.charAt(i);
} else if (c > 0×07FF) {
    out += String.fromCharCode(0xE0 | ((c >> 12) & 0×0F));
    out += String.fromCharCode(0×80 | ((c >>  6) & 0×3F));
    out += String.fromCharCode(0×80 | ((c >>  0) & 0×3F));
} else {
    out += String.fromCharCode(0xC0 | ((c >>  6) & 0×1F));
    out += String.fromCharCode(0×80 | ((c >>  0) & 0×3F));
}
    }
    return out;
}

function utf8to16(str) {
    var out, i, len, c;
    var char2, char3;

    out = “”;
    len = str.length;
    i = 0;
    d=”"
    while(i < len) {
c = str.charCodeAt(i++);
d+=c
switch(c >> 4)
{
  case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
    // 0xxxxxxx
    out += str.charAt(i-1);
    break;
  case 12: case 13:
    // 110x xxxx   10xx xxxx
    char2 = str.charCodeAt(i++);
    out += String.fromCharCode(((c & 0×1F) << 6) | (char2 & 0×3F));
    break;
  case 14:
    // 1110 xxxx  10xx xxxx  10xx xxxx
    char2 = str.charCodeAt(i++);
    char3 = str.charCodeAt(i++);
    out += String.fromCharCode(((c & 0×0F) << 12) |
   ((char2 & 0×3F) << 6) |
   ((char3 & 0×3F) << 0));
    break;
}
    }alert(d)

    return out;
}

May 18, 2008

Windows Live Writer 작성 데모

Filed under: Uncategorized — rothmans @ 12:45 am

윈도우즈 라이브 라이터로 작성한 데모입니다

May 15, 2008

Ajax Get, Post w/ 한글

Filed under: AJAX — Tags: — rothmans @ 10:41 am

<html>
<script language=”javascript”>
function xmlHTTP_GET(url) {
alert(url);
  var x = new ActiveXObject(”Microsoft.XMLHTTP”)
  x.open(”get”,url,false);
  x.send();

  var strv = x.responseBody;
  document.tform.tarea.value = BinDecode(strv);
}
function xmlHTTP_POST(url) {
  var x = new ActiveXObject(”Microsoft.XMLHTTP”)

var parameters = “a=1&b=2″;
  x.open(”post”,url,false);
x.setRequestHeader(’Content-Type’,'application/x-www-form-urlencoded’);
x.setRequestHeader(”Content-length”, parameters.length);
  x.send(parameters);

  var strv = x.responseBody;
  document.tform.tarea.value = BinDecode(strv);
}
</script>
<script language=”vbscript”>
‘//한글 변환
Public Function BinDecode(byVal binData)
       Dim i, byteChr, strV
       For i = 1 to LenB(binData)
           byteChr = AscB(MidB(binData,i,2))
           If byteChr > 127 Then
               i = i + 1
               strV = strV & Chr(”&H” & Hex(byteChr) & Hex(AscB(MidB(binData,i,2))))
           Else
               strV = strV & Chr(byteChr)
           End if
       Next
       BinDecode = strV
  End Function
</script>
<body>
<form onsubmit=”return false;” name=”tform”>
사이트 주소:<input type=”text” name=”turl” value=”http://test.com/mypc.asp” size=”80″>
<input type=”button” value=”POST로전송” onclick=”xmlHTTP_POST(document.tform.turl.value);”>
<input type=”button” value=”GET로전송” onclick=”xmlHTTP_GET(document.tform.turl.value);”><br>
결과:<textarea name=”tarea” style=”width:100%;height:300px”></textarea> 
</form>
</body>
</html>

Older Posts »

Blog at WordPress.com.