Question SQL EXPRESS Connection Problem

S37N

Member
Joined
Jul 12, 2012
Messages
8
Programming Experience
1-3
I have Visual Studio 2010, with SQL EXPRESS which came with VS2010 from what I understand. I built a database in my VB.NET project, and am trying to copy data from the corporate SQL SERVER to my VB.NET created database (SQL EXPRESS).

Below I've included my script, with both connection strings. The SQL SERVER version works, but not the SQL EXPRESS one. If anyone could led me in the right direction, it would be much appreciated.

VB.NET:
[COLOR=#000000][FONT=verdana]
[/FONT][/COLOR]Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

'SQL EXPRESS COnnection String
Dim con As SqlConnection = New SqlConnection("Server=OVP-L-R8MXE5M\SQLEXPRESS;" & "Database=dbTest;" & "Trusted_Connection=TRUE;")

'SQL SERVER COnnection String
'Dim con As SqlConnection = New SqlConnection("Server = ***-*-*******;" & "Database = CMP;" & "Trusted_Connection=TRUE")

con.Open()

Dim cmd As SqlCommand = New SqlCommand("INSERT INTO dbTest.cbo.tblFactSales ( BILLTO,BRANCHPLANT,COMPANY,DATASRC,DATATYPE,FRTHANDLE,MODE,ORDERTYPE,ORIGINPLANT,PRODUCT,RPTCURRENCY,SALESDATA,SHIPTO,TIMEID,SIGNEDDATA,SOURCE ) " & _                                                "SELECT CMP.dbo.tblFactSales.*  " & _
"FROM CMP.dbo.tblFactSales " & _
"WHERE DATATYPE='FORECAST' AND TIMEID='20120700'", con)

cmd.ExecuteNonQuery()

MessageBox.Show("Records Moved Successfully.", "Move Complete", _
MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) [LEFT][COLOR=#000000] 
End Sub
[/COLOR][/LEFT]

:confused:
 
Last edited:
There are a couple of different ways to format a connection string... This one has worked for me on both full SQL Server, Express, and Compact...

VB.NET:
Data Source=MACHINENAME\SQLINSTANCE;Initial Catalog=AdventureWorks2008;Integrated Security=SSPI;
Data Source=MACHINENAME\SQLINSTANCE;Initial Catalog=AdventureWorks2008;User ID=Tom;Password=TheCat;
 
i found that my SQL install was misconfigured. problem resolved. I used SQL import/export tool once install was corrected.
 

Latest posts

Back
Top