Home All Groups Group Topic Archive Search About

connect vb app to sql 2005 express

Author
29 Nov 2006 6:34 PM
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

Author
29 Nov 2006 7:35 PM
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.
Author
29 Nov 2006 9:43 PM
josh
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=|DataDirectory|\testdatabase.mdf;Integrated
Security=True;User Instance=false"

I get this error when I debug the application:

Invalid value for key 'attachdbfilename'
Author
29 Nov 2006 11:52 PM
Robinson
Try:

"server=MYSERVER\SQLEXPRESS;initial catalog=testdatabase;integrated
security=True"
Author
30 Nov 2006 1:09 AM
FishingScout
Did you configure SQL Server Express for remote connections? Remote
connections are disabled by default.


j***@adnetss.com wrote:
Show quoteHide quote
> 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=|DataDirectory|\testdatabase.mdf;Integrated
> Security=True;User Instance=false"
>
> I get this error when I debug the application:
>
> Invalid value for key 'attachdbfilename'
Author
30 Nov 2006 4:37 AM
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 c**t.

Steve Ray Irwin


j***@adnetss.com wrote:
Show quoteHide quote
> 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=|DataDirectory|\testdatabase.mdf;Integrated
> Security=True;User Instance=false"
>
> I get this error when I debug the application:
>
> Invalid value for key 'attachdbfilename'
Author
30 Nov 2006 6:20 AM
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


On 29 Nov 2006 20:37:30 -0800, Master Programmer wrote:

Show quoteHide quote
> 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 c**t.
>
> Steve Ray Irwin
>
> j***@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=|DataDirectory|\testdatabase.mdf;Integrated
>> Security=True;User Instance=false"
>>
>> I get this error when I debug the application:
>>
>> Invalid value for key 'attachdbfilename'
Author
30 Nov 2006 5:10 PM
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...

Master Programmer wrote:
Show quoteHide quote
> 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 c**t.
>
> Steve Ray Irwin
>
>
> j***@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=|DataDirectory|\testdatabase.mdf;Integrated
> > Security=True;User Instance=false"
> >
> > I get this error when I debug the application:
> >
> > Invalid value for key 'attachdbfilename'
Author
30 Nov 2006 9:40 PM
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

On 30 Nov 2006 09:10:57 -0800, FishingScout wrote:

Show quoteHide quote
> 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 c**t.
>>
>> Steve Ray Irwin
>>
>>
>> j***@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=|DataDirectory|\testdatabase.mdf;Integrated
>>> Security=True;User Instance=false"
>>>
>>> I get this error when I debug the application:
>>>
>>> Invalid value for key 'attachdbfilename'
Author
30 Nov 2006 11:06 PM
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***@adnetss.com wrote:
Show quoteHide quote
> 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
Author
1 Dec 2006 5:40 AM
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



FishingScout wrote:
Show quoteHide quote
> 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***@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
Author
2 Dec 2006 6:54 PM
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***@adnetss.com wrote:
Show quoteHide quote
> 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.
> >
> >
> > j***@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
Author
3 Dec 2006 5:51 AM
josh
Thanks Fishing Scout, I got the basic query to work. I appreciate your
patience with me.

Thanks again,
Josh


FishingScout wrote:
Show quoteHide quote
> 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***@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.
> > >
> > >
> > > j***@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
Author
18 Dec 2006 3:59 PM
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.

*** Sent via Developersdex http://www.developersdex.com ***