1,105,406 Community Members

VB.NET connection to SQL SERVER

Member Avatar
gispe
Junior Poster in Training
75 posts since Jul 2008
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi all,
i started programming with .NET (i have express edition) and wanted to make a conection to an SQL Server.. the problem is that i cant conect :(
previously i had .net 2005 - i started having the issue there - i unistalled it, n installed visual studio 2008.
I have installed SQL Compact that came with the .net 2008, and besides it SQL Server 2000.

When I try to make a conection to the SQL Server, if server is running I have to stop it and then choose the DB i want to use. (if its running wont let me choose any DB). Then, when i select the DB i need, Im getting this error:

"The instruction CREATE FILE fount SO error 5 (failed to retrieve text for this error.Reason:15105) while trying to open or creating the fysichal file : -path- to northwnd_log.ldf.
Cant open the new database -path to northwnd.mdf. CREATE DATABASE discarded.
Error while trying to attach a DB automatically named for archive -path to northwnd.mdf. There already exists a database with the same name, cant open the specified file or it is in a shared UNC resourse.
File activation error. File name -path to northwnd_log.ldf- might be wrong"


And when i try to connect with the SQL compact edition that came installed with the visual studio, im getting this error:

"Can not allow access to the file in DB [File name = path to northwind.sdf]"


And dont know what is that im doing wrong.

Member Avatar
finito
Nearly a Posting Virtuoso
1,264 posts since May 2010
Reputation Points: 46 [?]
Q&As Helped to Solve: 140 [?]
Skill Endorsements: 0 [?]
 
0
 

You messed up the installs.

Uninstall everything and Restart.

Then install what you need again.

Member Avatar
gispe
Junior Poster in Training
75 posts since Jul 2008
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

so i have to reinstall all over again???

Member Avatar
finito
Nearly a Posting Virtuoso
1,264 posts since May 2010
Reputation Points: 46 [?]
Q&As Helped to Solve: 140 [?]
Skill Endorsements: 0 [?]
 
0
 

yup thats what i said.

Member Avatar
gispe
Junior Poster in Training
75 posts since Jul 2008
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i just reinstalled vb.net, and could conect to a sql server compact (came with vb.net) ..
and when trying to make a query into the northwind db, im getting : "error while trying to create de consult, there is no assigment of DbType Ofject to any known SQL Server Compact data type"

Member Avatar
finito
Nearly a Posting Virtuoso
1,264 posts since May 2010
Reputation Points: 46 [?]
Q&As Helped to Solve: 140 [?]
Skill Endorsements: 0 [?]
 
0
 

Code please

What is the query you made.

Member Avatar
gispe
Junior Poster in Training
75 posts since Jul 2008
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

the code im using is:

SELECT SupplierID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax, HomePage FROM dbo.Suppliers where SupplierID= @SupplierIDParam
Member Avatar
finito
Nearly a Posting Virtuoso
1,264 posts since May 2010
Reputation Points: 46 [?]
Q&As Helped to Solve: 140 [?]
Skill Endorsements: 0 [?]
 
0
 

Looks good, can you post your code.

there is no assigment of DbType Ofject to any known SQL Server Compact data type"

This basically means you either didn't make the connection string correctly or You didn't initialize something.

Member Avatar
gispe
Junior Poster in Training
75 posts since Jul 2008
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i just re-done the connection all over again..
here is a screen shot on where im now

Attachments vbnet.doc (101.5KB)
Member Avatar
gispe
Junior Poster in Training
75 posts since Jul 2008
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

in String Connection, i just noticed that i have: DataSource=|DataDirectory|\Northwind.sdf

should it be c:\... and all the path till the database?

probably very stupid question.. but idk :$

Member Avatar
finito
Nearly a Posting Virtuoso
1,264 posts since May 2010
Reputation Points: 46 [?]
Q&As Helped to Solve: 140 [?]
Skill Endorsements: 0 [?]
 
0
 

I asked for code m8.

DataSource=|DataDirectory|\Northwind.sdf

It looks like that is auto generated it should be fine.

Member Avatar
gispe
Junior Poster in Training
75 posts since Jul 2008
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

re-done it again.. checked the connection String and has the whole path to the db.. the db in the DB explorer is conected.. BUT let me make the sql query without the where clause..
any idea why this happend and how can i make to use the where clause??

thanks in advance!! :)

Member Avatar
finito
Nearly a Posting Virtuoso
1,264 posts since May 2010
Reputation Points: 46 [?]
Q&As Helped to Solve: 140 [?]
Skill Endorsements: 0 [?]
 
0
 

Seriously?

Do you think I am a psychic? or maybe Yoda?

I asked for one thing the past three posts, which you failed to provide.

Unless you think I GOD, I think you are trolling to just get on my nerves, which you have succeeded in doing.

Member Avatar
gispe
Junior Poster in Training
75 posts since Jul 2008
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

to make the connection im using a wizard, so i dont have code to paste here. unless u want to have all the screen shots of what im doin..
the sql code, pasted in one of my previous posts

Member Avatar
finito
Nearly a Posting Virtuoso
1,264 posts since May 2010
Reputation Points: 46 [?]
Q&As Helped to Solve: 140 [?]
Skill Endorsements: 0 [?]
 
0
 

Try and run your SQL query in the SQL Browser.

you should understand what you did wrong.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: