connect vb app to sql 2005 express

J

josh

I'm pretty new to both sql 2005 and VB but please bear with me. I have
installed SQL 2005 express on a Windows 2003 Standard server. I have
also installed VB 2005 Express edition on the server. SQL seems to be
running fine (I can create databases, tables, modify them, etc.) I have

created a very basic app in VB express that just lets me view and
modify the current tables. It works just fine on the server. However, I

am trying to make this app connect from an XP pro machine on the
network and I really don't know where to start. I tried running the app

that works locally over the network and I get "error 26" can't connect
to database server. I've read about using strings and ADO but I'm not
familiar enough with VB to make it work. Also, both machines are on the

same network and I can connect to the server from the XP pro machine
with SQL server management studio express.

Any help is greatly appreciated.
Thanks,
Josh
 
I

IdleBrain

It is kind of hard for someone to know what the problem is unless you
post some of your code. Specially..the code you use to connect your APP
to the Database.
 
J

josh

IdleBrain said:
It is kind of hard for someone to know what the problem is unless you
post some of your code. Specially..the code you use to connect your APP
to the Database.





here is what i am trying for the connection string. It is supposed to
run when the main form loads.


Dim conn As New SqlConnection()
conn.ConnectionString = "Data
Source=MYSERVER\SQLEXPRESS;AttachDbFilename=|DataDirectory|\testdatabase.mdf;Integrated
Security=True;User Instance=false"

I get this error when I debug the application:

Invalid value for key 'attachdbfilename'
 
R

Robinson

Try:

"server=MYSERVER\SQLEXPRESS;initial catalog=testdatabase;integrated
security=True"
 
F

FishingScout

Did you configure SQL Server Express for remote connections? Remote
connections are disabled by default.
 
M

Master Programmer

Why do you automatically expect answers from this forum? Many of us
spend a great deal of time trying to help people that have genuinely
exhausted all avenues of research _BEFORE_ asking questions here.

I suggest that you first search the web for information to do something
as basic as this. Don't just come here asking questions and expecting
answers like an arrogant ****.

Steve Ray Irwin
 
A

al jones

I relly know better than this - he comes here because many of us are
ignorant, not stupid, not dumb but ignorant. Like my question earlier
today, once I had the answer it was obvious, but I hadn't seen it before
and really didn't expect it to be what it was, and hence had no realistic
idea of where to look.

I remember the day when I was the newbie coding COBOL (yes *many* long
years ago) I also remember being the person they came to later when 'things
just didn't jive' - and because I was able to remember being the newbie it
was easy to give the new newbies some help. Maybe you need to think back
and remember what it was like when you had to ask the 'dumb questions',
eh??

//al
 
F

FishingScout

That isn't helpful. If you believe the information is available online
somewhere then provide the links to the online information and describe
how you found it. A person reading that information will learn their
answer as well as how to better search for information. You will be
teaching someone, which is helpful, rather than discouraging them.

Looky there! I just helped you, by politely telling you, how you can be
a better mentor...
 
A

al jones

I don['t think either of us, Scout, is going to get an answer. Maybe it
has something to do with being sensible and polite.

//al
 
F

FishingScout

Josh,

In case you haven't found the solution. You need to use the surface
area configruation utility.

I did a google search for:

how to configure sql server express for remote connections

and found the msdn article:

http://support.microsoft.com/kb/914277

I went through this during my first installation about 6 months ago,
there are just a few steps to follow, which are clearly stated in this
article.
 
J

josh

Sorry, I tried to reply earlier but I think my connection timed out or
something. Thanks again for the help though.

I went through the surface area configuration tool and enabled TCP/IP
and named pipes. I also started the browser service and there isn't any
kind of firewall running. I restarted the SQL server service after this
of course. Later on I was toying around with an ASP page that was able
to connect to the server and perform a query. So, now it seems that
remote connections are enabled and working and my problem lies on the
VB side of things.

Also, I changed the connection string to
"server=MYSERVER\SQLEXPRESS;initial catalog=testdatabase;integrated
security=True" as Robinson suggested.

I then use this code in hopes of performing a query:

Dim testquery As New SqlCommand
testquery.CommandType = CommandType.Text
testquery.CommandText = "SELECT * FROM table1"
testquery.Connection = conn


I don't get the error when I debug it anymore, but the query doesn't
seem to be working correctly.

Thanks,
Josh
 
F

FishingScout

Try something like this:

Dim dbCommand As New SqlCommand("select * from table1")
dbCommand.Connection = conn
dbCommand.CommandType = CommandType.Text

Dim MyDataReader As SqlDataReader = dbCommand.ExecuteReader

Dim FirstColValues As ArrayList = New ArrayList

Do While MyDataReader.Read()

Dim FirstColValue As Integer = MyDataReader.GetValue(0)
FirstColValues.Add(FirstColValue)

Loop

MyDataReader.Close()
 
J

josh

Thanks Fishing Scout, I got the basic query to work. I appreciate your
patience with me.

Thanks again,
Josh
 
R

Rod Taylor

I am having the same problem
First I have installed SQL Server 2005 express on both machines. Do I
need to remove the SQL Server express form the machine not running the
database
I have a program that i wrote in vb 2005 express and it uses a database
in SQL express on each machine but now I want to share the database
within a network. I have searched and I have seen pages on configuring
SQL Server express for remote use. I am still a bit confused on this.
However I think my biggest problem is getting the program to run on the
client machine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top