468,251 Members | 1,399 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,251 developers. It's quick & easy.

connect vb app to sql 2005 express

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

Nov 29 '06 #1
13 1886
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.

Nov 29 '06 #2

IdleBrain wrote:
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=|DataD irectory|\testdatabase.mdf;Integrated
Security=True;User Instance=false"

I get this error when I debug the application:

Invalid value for key 'attachdbfilename'

Nov 29 '06 #3

Try:

"server=MYSERVER\SQLEXPRESS;initial catalog=testdatabase;integrated
security=True"
Nov 29 '06 #4
Did you configure SQL Server Express for remote connections? Remote
connections are disabled by default.
jo**@adnetss.com wrote:
IdleBrain wrote:
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=|DataD irectory|\testdatabase.mdf;Integrated
Security=True;User Instance=false"

I get this error when I debug the application:

Invalid value for key 'attachdbfilename'
Nov 30 '06 #5
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 cunt.

Steve Ray Irwin
jo**@adnetss.com wrote:
IdleBrain wrote:
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=|DataD irectory|\testdatabase.mdf;Integrated
Security=True;User Instance=false"

I get this error when I debug the application:

Invalid value for key 'attachdbfilename'
Nov 30 '06 #6
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
On 29 Nov 2006 20:37:30 -0800, Master Programmer wrote:
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 cunt.

Steve Ray Irwin

jo**@adnetss.com wrote:
>IdleBrain wrote:
>>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=|Data Directory|\testdatabase.mdf;Integrated
Security=True;User Instance=false"

I get this error when I debug the application:

Invalid value for key 'attachdbfilename'
Nov 30 '06 #7
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...

Master Programmer wrote:
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 cunt.

Steve Ray Irwin
jo**@adnetss.com wrote:
IdleBrain wrote:
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=|DataD irectory|\testdatabase.mdf;Integrated
Security=True;User Instance=false"

I get this error when I debug the application:

Invalid value for key 'attachdbfilename'
Nov 30 '06 #8
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

On 30 Nov 2006 09:10:57 -0800, FishingScout wrote:
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...

Master Programmer wrote:
>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 cunt.

Steve Ray Irwin
jo**@adnetss.com wrote:
>>IdleBrain wrote:
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=|Dat aDirectory|\testdatabase.mdf;Integrated
Security=True;User Instance=false"

I get this error when I debug the application:

Invalid value for key 'attachdbfilename'
Nov 30 '06 #9
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.
jo**@adnetss.com wrote:
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
Nov 30 '06 #10
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

FishingScout wrote:
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.
jo**@adnetss.com wrote:
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
Dec 1 '06 #11

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()
jo**@adnetss.com wrote:
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

FishingScout wrote:
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.
jo**@adnetss.com wrote:
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
Dec 2 '06 #12
Thanks Fishing Scout, I got the basic query to work. I appreciate your
patience with me.

Thanks again,
Josh
FishingScout wrote:
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()
jo**@adnetss.com wrote:
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

FishingScout wrote:
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.
>
>
jo**@adnetss.com wrote:
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
Dec 3 '06 #13


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.

*** Sent via Developersdex http://www.developersdex.com ***
Dec 18 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by LamSoft | last post: by
9 posts views Thread by Peter Lux | last post: by
2 posts views Thread by s j shah | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.