VB.net 2010 complains about SQL version

Background info I have SQL 2005, 2008, and 2012 installed. I am running VB.net 2010. In my my program I have checked my connection with the modify connection and went to advanced and checked my data source. I have 4 sources .\SQLexpress, ., .\sqlexpress2008, and .\act7. I am using "." the rest fail connection test giving me 661 or 655 can not connect to 706.  I am trying to use linq to sql and when I try to "database.submitchanges()" i get the following error.

The database 'C:\database\FIRSTDB.MDF' cannot be opened because it is version 706. This server supports version 655 and earlier. A downgrade path is not supported.
Could not open new database 'C:\database\FIRSTDB.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file C:\database\firstdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

The code im using for the datacontext
Public Class lqdc
        Inherits DataContext
        Public invoices As Table(Of Invoice)

        Public Sub New(ByVal connection As String)
            MyBase.new(Connection)
        End Sub


    End Class

Private Sub btnCommit_Click(sender As System.Object, e As System.EventArgs) Handles btnCommit.Click

 Dim database As New lqdc("C:\database\firstdb.mdf")

        Dim AddInvoice As New Invoice
        AddInvoice.OrgId = cbOrgId.SelectedValue
        AddInvoice.ClientId = cbClientId.SelectedValue
        AddInvoice.TechId = cbTechId.SelectedValue
        AddInvoice.theDate = dtpDate.Value
        AddInvoice.Notes = txtNotes.Text
        AddInvoice.Parts = txtParts.Text
        AddInvoice.Labor = txtLabor.Text
        AddInvoice.Mileage = txtMileage.Text
        AddInvoice.TotalCost = txtTotalCost.Text
        AddInvoice.InvoiceNumber = txtInvoiceNumber.Text

        database.invoices.InsertOnSubmit(AddInvoice)
        'errors out right here with using older connection for some reason.        
         database.SubmitChanges()
        
    End Sub

Open in new window


So why is it in Visual Basic using an older version of SQL to submit my code?
LVL 1
easyworksAsked:
Who is Participating?
 
CodeCruiserCommented:
Did you say you are only using . as datasource in connection string?

Are all the servers installed as named instances? Any server installed with default instance?
0
 
easyworksAuthor Commented:
Yes, I am only use "." as my datasource connection string.

Data Source=.;AttachDbFilename=C:\database\firstdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True

I got this generated from VB.net Data Connection.
0
 
Éric MoreauSenior .Net ConsultantCommented:
according to http://blogs.msdn.com/b/pranav_rastogi/archive/2012/02/20/mapping-sql-mdf-file-versions-to-sql-product-versions.aspx, your database was created with SQL 2012. to use it, you need to connect to it using SQL 2012.

Your default instance (.) is SQL 2008.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
easyworksAuthor Commented:
I guess maybe somehow I've never created a instance of SQL 2012, and have created my DB in SQL management studio... How do I create a new instance of SQL server 2012; just install SQL express 2012 again?
0
 
easyworksAuthor Commented:
I ran through an upgrade and this is a screenshot of what i had. I guess the SQL 2012 engine got installed but no instances of it. So what would be best thing to do just upgrade the instance of 2008 or try to install a new instance itself like .\SQL2012

sql instances
0
 
easyworksAuthor Commented:
I mean the only 2 instances that show up in VB2010 is . and .\sql2008 so ive always just assumed that the . could only be "MSSQLSERVER".

I went through another installation of SQL 2012 express. This time instead of choosing default instance I made it SQLEXPRESS2012.

I went into my project removed the old data connection and created a new connection and used .\SQLEXPRESS2012 as my datasource. Changed my app.config file to use .\SQLEXPRESS2012 as the datasource. Whenever i run my code though I'm still getting the same error. I don't understand how this is happening because at one point my DB was working to where I was able to submit data, but I was using datasets instead of LINQ to SQL. I don't see anywhere else in my project that I can change or modify how VB2010 is handling the connection by, which datasource it is choosing.

Also for kicks I created a new project. This is all my code and I get the same error. The only thing in this is LINQtoSQL.dbml file which is using the data connections that specifically is using the new .\sqlexpress2012 instance I created.

Imports System.Data.Linq
Public Class Form1

    Public Class lqdc
        Inherits DataContext
        Public invoices As Table(Of Invoice)

        Public Sub New(ByVal connection As String)
            MyBase.new(connection)
        End Sub
    End Class


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim database As New lqdc("C:\SkyDrive\VB\ewisql\Database\firstdb.mdf")

        Dim AddInvoice As New Invoice
        AddInvoice.OrgId = txtOrgId.text
        AddInvoice.ClientId = txtClientId.text
        AddInvoice.TechId = txtTechId.text
    
        database.invoices.InsertOnSubmit(AddInvoice)
        database.SubmitChanges()
    End Sub
End Class

Open in new window


snippet from my app.config
<connectionStrings>
        <add name="Project.My.MySettings.firstdbConnectionString" connectionString="Data Source=.\SQLEXPRESS2012;AttachDbFilename=C:\SkyDrive\VB\ewisql\Database\firstdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

Open in new window

0
 
CodeCruiserCommented:
Public Sub New(ByVal connection As String)
            MyBase.new(connection)
        End Sub

You are passing correct connectionstring to your form right?
0
 
easyworksAuthor Commented:
Dim database As New lqdc("C:\SkyDrive\VB\ewisql\Database\firstdb.mdf") 

Open in new window


for DataContext
0
 
CodeCruiserCommented:
You are only specifying a database filename there. Have you tried with a full connection string?
0
 
easyworksAuthor Commented:
Didnt know the file context needed more. Was example given by msdn how to setup a proper datacontext.

Creating a Strongly Typed View of Your Database
http://msdn.microsoft.com/en-us/library/bb399346
0
 
CodeCruiserCommented:
In that link

' Use a connection string.
Dim db As New Northwind _
    ("C:\linqtest\northwnd.mdf")

So if they are using a file does not mean you have to. DBContext accepts a connection string and that is how I have used it.
0
 
easyworksAuthor Commented:
so that wasnt referring to?

Public Class Northwind
    Inherits DataContext
    ' Table(Of T) abstracts database details  per
    ' table/data type.
    Public Customers As Table(Of Customer)
    Public Orders As Table(Of Order)

    Public Sub New(ByVal connection As String)
        MyBase.New(connection)
    End Sub
End Class

Open in new window

0
 
CodeCruiserCommented:
That's your class which is inheriting from DBContext. See that New method which takes a connection string and passes to the base class?
0
 
easyworksAuthor Commented:
I'm pretty sure its just what is reffering to that line of code now that you need to do. if you look at the next line it says query because thats what the line is doing.

I'm really beyond done with this and i'm going to just uninstall all of SQL and just install 2012 express. I appreciate all the help youve given me.
0
 
easyworksAuthor Commented:
Uninstalling all SQL items in add remove programs and then installing SQL express 2012 seems to have fixed my problem without having to change my code.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.