?
Solved

VB.net 2010 complains about SQL version

Posted on 2012-08-11
15
Medium Priority
?
1,606 Views
Last Modified: 2012-08-15
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?
0
Comment
Question by:easyworks
  • 9
  • 5
15 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 750 total points
ID: 38285223
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
 
LVL 1

Author Comment

by:easyworks
ID: 38288074
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
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 750 total points
ID: 38290050
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:easyworks
ID: 38290582
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
 
LVL 1

Author Comment

by:easyworks
ID: 38290590
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
 
LVL 1

Author Comment

by:easyworks
ID: 38290596
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38292351
Public Sub New(ByVal connection As String)
            MyBase.new(connection)
        End Sub

You are passing correct connectionstring to your form right?
0
 
LVL 1

Author Comment

by:easyworks
ID: 38292558
Dim database As New lqdc("C:\SkyDrive\VB\ewisql\Database\firstdb.mdf") 

Open in new window


for DataContext
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38293374
You are only specifying a database filename there. Have you tried with a full connection string?
0
 
LVL 1

Author Comment

by:easyworks
ID: 38293406
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38293440
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
 
LVL 1

Author Comment

by:easyworks
ID: 38293457
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38293466
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
 
LVL 1

Author Comment

by:easyworks
ID: 38293594
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
 
LVL 1

Author Comment

by:easyworks
ID: 38296428
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question