我首先遇到代码的ADS11连接字符串问题,
我尝试了很多方法,但我做不到。
有人知道,请指教。
这是我的工作环境。
服务器:Advantage Database Server 11
路径:\ ADS_DB:6262 \ DB \ DBB.ADD(端口:6262)
测试访问表:WEBORDERLN(ADT类型)
PK:PK(Char(36))我下载了Advantage.Data.Provider v11和Advantage.Data.Entity v11。 并添加参考。
的Web.config
<connectionStrings>
<add name="Ads_Context" connectionString="Data Source=\\ADS_DB:6262\DB\DBB.ADD;User ID=xxx;Password=xxx;ServerType=REMOTE;" providerName="Advantage.Data.Provider" />
</connectionStrings>
控制器,
public class Ads_Context : DbContext
{
public Ads_Context(): base("name=Ads_Context")
{
}
public DbSet<WebOrderLN> webOrderLns { get; set; }
}
public class HomeController : Controller
{
//
// GET: /Home/
public string Index()
{
var context = new Ads_Context().webOrderLns.ToList(); // Source error point to here
return "A";
}
}
[Table("WEBORDERLN")]
public class WebOrderLN
{
[Key]
public string PK {get; set;}
public string FK { get; set; }
public string pickno { get; set; }
}
当我运行上面的代码时,我收到一条错误消息,
Server Error in '/' Application.
Error 7200: AQE Error: State = HY000; NativeError = 5174; [iAnywhere Solutions][Advantage SQL][ASA] Error 5174: Advantage failed to open the specified link. dbo: Error 7041: File not found. Verify the specified path and file name is correct. Table name: WEBORDERLN AdsCommand query execution failed.
有人知道,我做错了吗?
答案 0 :(得分:2)
尝试在代码中向表中添加:: this的模式名称。
[Table( "WEBORDERLN", Schema = "::this" )]
public class WebOrderLN
{
[Key]
public string PK {get; set;}
public string FK { get; set; }
public string pickno { get; set; }
}
请参阅此知识库项目 http://devzone.advantagedatabase.com/dz/content.aspx?Key=17&RefNo=120423-2510