打开与OLEDB的连接会终止代码

时间:2017-06-26 19:06:54

标签: c# asp.net ado.net oledb dbase

我正在尝试在C#中创建一个dbf文件。不知何故,当我尝试打开与OLEDB的连接时,程序终止而不会抛出异常。以下是代码:

private void CreateDBFFile()
    {
        try
        {
            using (var dBaseConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; " + @" Data Source=k:\Temp; " + @"Extended Properties=dBase IV"))
            {
                dBaseConnection.Open();

                string createTableSyntax =
                    "Create Table Person " +
                    "(Name char(50), City char(50), Phone char(20), Zip decimal(5))";
                var cmd = new OleDbCommand(createTableSyntax, dBaseConnection);
                cmd.ExecuteNonQuery();
            }
        }
        catch (Exception ex)
        {
            string x = ex.Message;

        }

    }

错误就在这里:

dBaseConnection.Open();

我检查了事件日志,这也没有帮助。以下是事件日志中的错误日志:'

Faulting application name: iisexpress.exe, version: 10.0.14358.1000, time 
stamp: 0x574fc56b
Faulting module name: clr.dll, version: 4.6.1649.1, time stamp: 0x58f97fe6
 Exception code: 0xc0000005
Fault offset: 0x0045068d
 Faulting process id: 0x3354
 Faulting application start time: 0x01d2eeacd40d1e91
Faulting application path: C:\Program Files (x86)\IIS Express\iisexpress.exe
 Faulting module path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
 Report Id: 18960866-5aa0-11e7-b3f6-005056c00008

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:1)

我从连接字符串中删除此行

     "Extended Properties=dBase IV ". 

代码开始工作。

答案 1 :(得分:0)

您的连接方式并不理想。

执行此操作,然后单步执行代码,您应该能够获得异常,否则它将起作用: 将您的连接字符串放在web.config中。

const uniforms = {
  time: { value: 0 },
  tex1: { type: 't', value: null },
  tex2: { type: 't', value: null },
  tex3: { type: 't', value: null },
  activeTexture: { type: 'i', value: 0 },
  mixFactor:  { value: 0 }
}
const vertexShader = document.querySelector('#vertex-shader').text
const fragmentShader = document.querySelector('#fragment-shader').text

const geometry = new THREE.PlaneBufferGeometry(80, 40, 20, 20)
    const material = new THREE.ShaderMaterial({
    uniforms,
    vertexShader,
    fragmentShader
})

// textures are loaded here...

// transition using GSAP
function shift ()  {
    let ease = Power3.easeInOut
    if (counter === 0) {
      TweenMax.to(uniforms.mixFactor, 2, { value: 1, ease, onStart () {
        uniforms.activeTexture.value = 1
      } })
    } else if (counter === 1) {
      TweenMax.to(uniforms.mixFactor, 2, { value: 1, ease, onComplete () {
        uniforms.activeTexture.value = 2
      } })
   } else if (counter === 2) {
      TweenMax.to(uniforms.mixFactor, 2, { value: 2, ease, onComplete () {
        uniforms.activeTexture.value = 0
   } })


   console.log(uniforms.activeTexture.value)

   counter += 1
   if (counter === 3) counter = 0
}


// glsl
// morph between different targets depending on the passed int attribute

void main () {
  vec4 texColor = vec4(0.0);
  if (activeTexture == 0) {
  texColor = transition(tex1, tex2, vUv, mixFactor);
  } else if (activeTexture == 1) {
    texColor = transition(tex2, tex3, vUv, mixFactor);
  } else if (activeTexture == 2) {
    texColor = transition(tex3, tex1, vUv, mixFactor);
  }
  gl_FragColor = texColor;
}