我想连接密码保护访问。请告知我在哪里可以通过以下编码传递密码参数。
With Acon1
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=" + ThisWorkbook.Sheets(1).Range("V24").Value
.Open
End With
With Rs1
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.ActiveConnection = Acon1
.Source = "Select * from Headcount where [Employee ID]=" & myvalue0l
.Open
End With
答案 0 :(得分:0)
尝试:
using SecondApp.Controllers;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Caching;
using System.Web.Hosting;
namespace PathProviderSample
{
public class EmbeddedVirtualFile : VirtualFile
{
public EmbeddedVirtualFile(string virtualPath)
: base(virtualPath)
{
}
internal static string GetResourceName(string virtualPath)
{
if (!virtualPath.Contains("/Views/"))
{
return null;
}
var resourcename = virtualPath
.Substring(virtualPath.IndexOf("Views/"))
.Replace("Views/", "SecondApp.Views.")
.Replace("/", ".");
return resourcename;
}
public override Stream Open()
{
Assembly assembly = typeof(TestController).Assembly;
var resourcename = GetResourceName(this.VirtualPath);
return assembly.GetManifestResourceStream(resourcename);
}
}
public class Vpp : VirtualPathProvider
{
private bool ResourceFileExists(string virtualPath)
{
Assembly assembly = typeof(TestController).Assembly;
var resourcename = EmbeddedVirtualFile.GetResourceName(virtualPath);
var result = resourcename != null && assembly.GetManifestResourceNames().Contains(resourcename);
return result;
}
public override bool FileExists(string virtualPath)
{
return base.FileExists(virtualPath) || ResourceFileExists(virtualPath);
}
public override VirtualFile GetFile(string virtualPath)
{
if (!base.FileExists(virtualPath))
{
return new EmbeddedVirtualFile(virtualPath);
}
else
{
return base.GetFile(virtualPath);
}
}
}