我在我的Windows应用程序中添加了一个实体,这是我的整个代码。
Imports MSWord.FirstBSEntities
Private db As FirstBSEntities
Private Sub btnOpen_Click(sender As System.Object, e As System.EventArgs) Handles btnOpen.Click
AxEDOffice1.OpenFileDialog()
Dim Count As Integer = AxEDOffice1.WordGetPageCount
Dim Id As Integer = (From a In db.FirstBS Select a.BSId).FirstOrDefault()
Label1.Text = Id * Count
End Sub
App.Config中
<connectionStrings>
<add name="FirstBSEntities" providerName="System.Data.SqlClient"
connectionString="Data Source=SQL\SQL2008;Initial Catalog=FirstBS; Integrated Security=true" />
<!--<add name="FirstBSEntities" connectionString="Data Source=SQL\SQL2008;Initial Catalog=FirstBSEntities;User ID=sa;Password=P@ssw0rd" providerName="System.Data.SqlClient" />-->
<add name="FirstBSEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=SQL\SQL2008;initial catalog=FirstBS;user id=sa;password=P@ssw0rd;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
我是连接字符串的新手,我的linq
中出现了这个错误 Object reference not set to an instance of an object.