Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Database and Reporting > What database to use.


Reply
 
Thread Tools Display Modes
  #41  
Old 04-26-2012, 02:54 PM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is online now
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 1,908
Default


A connection string to a sql server is made up of different parts, not all required and some cannot be used together; a quick overview of the ones you are using follows....

Data Source is used to specify the server instance you wish to connect to. This takes to form of <servername>\<instancename> where . can be used to specify the local machine and <instancename> can be omitted if you are connecting to the default instance.
Data Source=.\SQLEXPRESS is therefore trying to connect to the instance named SQLExpress (the default name SQL Express uses) on the local machine.

Initial Catalog is used to specify the name of a database on the instance you are connecting to.

Integrated Security=Trueis telling the application to connect to the SQL Server Instance using your currently logged on credentials.

AttachDbFilename Is used to specify the path to a .mdf file to attach dynamically to an instance of SQL Server rather than requiring an administrator to have previously created or attached a DB to the server.

User Instance=True Is enabling a feature known as User Instances - this will create a new instance of SQL Server for the currently logged on user, this instance will run as the current user rather than as the typical windows service account (NT AUTHORITY\NETWORK SERVICE by default for SQL Server)

If you look at the above explanations then you can see that using a User Instance and a Data Source in the same connection string makes no sense, either you are connecting to a named instance or you require a User Instance.

Similarly if you are using Initial Catalog to connect to a database there is no sense in trying to also use AttachDbFilename to attach a database.

Are you trying to connect to a specific instance of SQL Express? IS the database already attached or is it just a file on disk?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #42  
Old 04-26-2012, 04:43 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

I don't want to connect to my master database at all. What
i have been trying to do all along was to connect and open
any database file that i choose, already on my hard drive.

All the databases that i try to connect to, don't have a password
or user ID. The process, should be simple and straight forward
but i guess i'm not understand how to open sql databases to well.

I'm trying to learn, through what code i have downloaded but even
microsoft code will not open any database on my hard drive.

I keep getting stuff like LOG-IN FAILED.

I need something that will tell either MSSQLSERVER or SQLEXPRESS
where to go to open my database and that's pretty much it.

I'm getting a sense that in order to do that though, i first have to log
in to my master database, before i can open the database that i really
want to open. From the code that i have been finding, this seems to be
the case.

Most of the time, i never get passed the:Example(con.open). The program
halts at that point because of log-in issues. I shouldn't have to put that
information in, unless i'm trying to change something in the master database.

I don't want to have to attach anything either, if that's possible.
Reply With Quote
  #43  
Old 04-26-2012, 05:02 PM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is online now
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 1,908
Default

The two options of AttachDbFilename and User Instance=true should allow you to do this then, you would simply pass the path to the .mdf file as the parameter for AttachDbFilename.

You are also going to need to specify some credentials for the database though, either a user name and password if the database is configured for that or use integrated security to use your current user account.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #44  
Old 04-26-2012, 05:49 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

OK. I'll try that then but it doesn't make much sense. If other
people can run the code that i've been downloading from them
and it works for them, then why don't it work for me?

Also, do i need to detach it when i'm done with it and what am
i attaching it to?


On a different but similar note, I got two different versions of the
same code that i want to share with you. The only different between
the two, is that in one of them, the code connects to the master database
with no trouble at all. No userID or password is required.

The second one, the only thing that changes is that instead of connecting
to the master database, i try to connect to northwind.mdf. Here is the
first one that works:

This one connects to the master database
and it works.
Code:
Imports System.Data.SqlClient
Public Class Form1
    Dim con As SqlConnection
    Dim DbName As String = "C:\Northwind.mdf"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=master;Integrated Security=SSPI")
        Dim cmd As New SqlCommand()
        '  cmd.CommandText = "PRINT('This raises an InfoMessage event')"
        cmd.Connection = con
        Try
            con.Open()
            MsgBox("Database Opened")
        Catch ex As Exception
            TextBox1.AppendText(ex.Message)
        Finally
            con.Close()
            MsgBox("Database Closed")
        End Try
    End Sub
End Class
This one has northwind as the database to connect to,
It doesn't work.
Code:
Imports System.Data.SqlClient
Public Class Form1
    Dim con As SqlConnection
    Dim DbName As String = "C:\Northwind.mdf"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As                 System.EventArgs) Handles MyBase.Load
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=" & DbName & ";Integrated Security=SSPI")
        Dim cmd As New SqlCommand()
        '  cmd.CommandText = "PRINT('This raises an InfoMessage event')"
        cmd.Connection = con
        Try
            con.Open()
            MsgBox("Database Opened")
        Catch ex As Exception
            TextBox1.AppendText(ex.Message)
        Finally
            con.Close()
            MsgBox("Database Closed")
        End Try
    End Sub
End Class
This is the error i get:

Cannot open database "C:\Northwind.mdf" requested by the login.
The login failed.
Login failed for user 'MyServerName'.
Reply With Quote
  #45  
Old 04-26-2012, 05:54 PM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is online now
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 1,908
Default

To answer the problem first - 'c:\Northwind.mdf' is the physical file name and not the logical name the database is registered as with SQL - try a database name of 'Northwind' and see if that works.

Regarding
Quote:
If other people can run the code that i've been downloading from them and it works for them, then why don't it work for me?
I am guessing that is because either their systems are setup differently or they are doing slightly different things.

Also if you are using the AttachDbFile then you are effectively dynamically attaching it for that connection, there is no permanent configuration change made and you don't need to detach the database afterwards.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #46  
Old 04-26-2012, 07:46 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

Nope. Now attaching a database isn't working. Once it's attached,
it needs to be detached in order to use that database again. If not,
you get this error message:

Database 'C:\Users\MyComputerName\Desktop\Databases\NORTHWIND.mdf'
already exists. Choose a different database name.
Cannot attach the file 'C:\Northwind.mdf' as database 'Overland'.


I was just trying to open the northwind database at c:\NorthWind But the
server must hold the information about what is attached or not. This sql
statement won't work for anything unless i get the NorthWind database
at 'C:\Users\MyComputerName\Desktop\Databases\NORTHWIND.mdf''
detached first.

Secondly, i think that attach code was meant to create a database because
of the error:

Cannot create file 'C:\Northwind_log.LDF' because it already exists.
Change the file path or the file name, and retry the operation.
Could not open new database 'Overland'. CREATE DATABASE is aborted.
Cannot attach the file 'C:\Northwind.mdf' as database 'Overland'.
File activation failure. The physical file name
"C:\Users\MyComputerName\Desktop\Databases\NORTHWIND_log.LDF" may be incorrect.


I removed the database from C drive and that is when i got that error.

I think i'm just going to have to give up on using SQL databases. I was trying to learn
it because it seems the SQL is the wave of the future, but going on 3 pages now of trying
the learn how to just open a database on a regular bases, and i still haven't gotten anywhere
with it, i'm just going to stop bugging you people and quit.

I thank all that tried to help me, but apparently, i can't seem to grasp it
very well and you efforts were wasted on me.

Thank you all very much....
Reply With Quote
  #47  
Old 04-27-2012, 02:14 AM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is online now
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 1,908
Default

If the database is already in use by an instance of SQL (this also includes your own application) then the file will be locked and you will be unable to attach it to a second SQL instance. There should be no need to deliberately detach a database from a named instance of SQL.

What connection strings / code did you use to get the two errors in your previous post?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #48  
Old 04-27-2012, 03:51 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

It doesn't even matter any more PlausiblyDamp. I give up on trying
to work with SQL databases.

I just can't seem to grasp the use of command strings. Not only that
but even when i find code online to use, none of it works on my laptop
either. I find that really strange. Isn't this stuff suppose to be portable
enough to use on computers that the program wasn't created on?
Reply With Quote
  #49  
Old 04-28-2012, 07:06 AM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is online now
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 1,908
Default

Sometimes there is more to programming than finding code on line and just doing a cut and paste into your own program and expecting it to work.

When you are using code found on the internet you need to make a bit of an investment in researching the objects used to decide if they are suitable and what exactly can / needs to be changed. Finding multiple similar "solutions" and randomly cutting and pasting bits from each without understand the principles or objects used will nearly always result in code that is either non-compiling or buggy if it compiles.

The various settings in a connection string are all documented for SQL on MSDN and the documentation makes it pretty clear what each setting does.

Quote:
Isn't this stuff suppose to be portable
enough to use on computers that the program wasn't created on?
When dealing with things like databases there is always the potential for your machine to be configured differently to the machine of the person who wrote the code you are copying, this means you will need to make adjustments for things like database names or file locations.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #50  
Old 04-28-2012, 06:26 PM
hDC_0 hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 523
Default Giving Up? Wasted time?

Quote:
I give up on trying to work with SQL databases.
I have a confession to make - I hate databases.
(I know they are the "bread-and-butter" of the programming world,
so I don't usually make a point of it, though.)

I love graphics programming and really don't like to get involved with the
threads asking database questions.

But really - giving up on SQL and databases in .Net after one thread?
(or midway through your first .Net database programming thread?)

This is the second thread (after your tiles thread) where you seem to have given up
before your project reached completion..
(although the tiles thread still have a few days left before it dies,
so I'm still hopeful you can finish working on some of the suggestions
given in that thread).

Anyway - I'm sensing a bad pattern forming
Do you give up on everything in life so easily?
(I know you do not from having read through all your VB6 posts)

I definitely want to give you some (looks like its needed) encouragement.

Nobody every said learning to program would be without effort.
Sometimes it can be a real grind.
But at least you don't have to totally go the trial-and-error route,
because you have experienced people here on the xvbt forum
who are here to help.

What the people on the forum can't help you with
is a "let's-just-give-up" attitude.

That's something you have to get past on your own
if you really want to be a programmer in .Net or any other language.

Quote:
i can't seem to grasp it very well and you efforts were wasted on me.
This is also a bit of "wrong" attitude.
In years to come you don't know how many other newbie .Net programmers
may come upon this thread in their internet searching.
Your "stupid" questions may provide just the answers to issues they were trying to get past.
In your "fumblings" you maybe their best teacher - did you consider that?
Wasted efforts - definitely not!

Instead of just randomly searching around on the internet,
start with the MSDN docs and work out from there:
SQL Commands and Functions
SqlConnection Constructor
System.Data.SqlClient Namespace
http://msdn.microsoft.com/en-us/libr...vs.110%29.aspx
Retrieving and Modifying Data in ADO.NET

I know the MSDN docs can be really dry (text-heavy),
and somewhat un-graphical.

After going through dozens and dozens of pages on database
specifics, I sometimes think:
Quote:
Can't the Microsoft documentors
just have one "trunk" list-of-overview-tutorials thread
that maybe references a few illustrations and diagrams?
MSDN has them they're just not always easy to find except through special Google image searching.
However, the above links are only a few of the hundreds
of MSDN SQL links I have bookmarked
(and I deal with SQL less than 1% of the time, but I know it's
important to really dig in and use MSDN fully as a resource,
in addition to asking for help on the forum).

Here's something you may learn only later in life.

One of the secrets to succeeding in life,
(as well as not getting to "brittle" as you get older)
is never stop trying to learn new things.

Last edited by hDC_0; 04-28-2012 at 07:08 PM.
Reply With Quote
  #51  
Old 04-30-2012, 03:23 AM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

PlausiblyDamp:

I have gone to MSDN on several occasions. I searched through many articles
concerning SQL and proper ways to use it. I've implemented their code on my
machine and i still can't even open a connection, let alone do anything with the
database.

I noticed that my machine and three different versions of SQL Server Configuration
Manager running at the same time. I had the 2005, 2008 and 2012 versions, so i
uninstalled the first two, with the thought that maybe SQL didn't know which one
to connect to. Now they have no choice but to connect to the 2012 version, or so i
thought. I'm still having the same problem. I can even make a connection. This should
be the easy part of database programming but apparently, it's not so easy for me. Either
i'm that stupid or something is wrong with my machine, that will not allow me to make
a connection. Which one is it?

I've actually downloaded several dozens of complete SQL programs, demonstrating different
uses for using a SQL database and none of them will make a connection either.

The only thing that would get me interested in SQL again, is if someone that programs using
VB Express 2012 on a 64 bit machine, could make me a program that just makes a successful
connection to a provided database. Not northwind or adventureworks but a dummy database,
made just for testing purposes.

I've done everything that i can do, to learn SQL and i'm no further along now than i was
when i first started.
Reply With Quote
  #52  
Old 04-30-2012, 03:46 AM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

hDC_0

I haven't given up on the map editor yet, if that is what your thinking. Using a
database to store tile sheets, was my next step in it's creation. I wanted to be
able to use more than one tile sheet at a time, like RPG Game Maker does. I
didn't want to have six to ten tile sheets that i had to keep track of on my hard
drive and storing them all in one database, just seemed to make sense.

Like i just told PlausiblyDamp, i've been to MSDN several times and even used
their code in my program, to open a connection to a database and still, i'm having
trouble doing this. So, for now, i quit trying to use SQL. Obviously, either i just
can't seem to learn it or something one my machine is preventing me from make a
connection.

Right now, I'm working with ADO. I can open the database and put it's contents into
a datagridview control. By typing into the datagrid, i can add records and delete them.

Right now, i'm learning how to programically add a new table to the database. I need
to learn how to set a primary key yet to but once i learn these things, i'm going to make
an ADO Database creator and editor. I can't find one online, so i'll make my own.

Once i get really good with that, i'll go back to my map maker and apply what i just
learned to that program.

I'll take a look at the links you just provided but chances are, i've already been there.

Thanks for the pep talk though. I feel a little better about myself now.....
Reply With Quote
  #53  
Old 04-30-2012, 05:29 AM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

I thought that i would give it another go with code that
i got from MSDN.

Code:
 Private Sub OpenSqlConnection()
        Dim connectionString As String = GetConnectionString()
        Using connection As New SqlConnection(connectionString)


            Try
                connection.Open()

            Catch ex As Exception
                MsgBox(ex.Message)
                Exit Sub
            End Try

            Console.WriteLine("ServerVersion: {0}", connection.ServerVersion)
            Console.WriteLine("State: {0}", connection.State)
        End Using
        MsgBox("Connection open")
       
    End Sub

    Private Function GetConnectionString() As String
        ' To avoid storing the connection string in your code,  
        ' you can retrieve it from a configuration file, using the
        ' System.Configuration.ConfigurationSettings.AppSettings property
        Return "Data Source=(local);Database=AdventureWorks;" _
          & "Integrated Security=SSPI;"
    End Function
With the Error handing, i just get a message saying that it couldn't
connect with the Adventureworks database.

I, originally got this code without error handling and i got this error:

Quote:
System.Data.SqlClient.SqlException was unhandled
Class=11
ErrorCode=-2146232060
LineNumber=65536
Message=Cannot open database "AdventureWorks" requested by the login. The login failed.
Login failed for user 'MyPCName'.
Number=4060
Procedure=""
Server=(local)
Source=.Net SqlClient Data Provider
State=1
Like i said before, I'm running on a 64 bit machine. I'm running the code
in 64 bit mode with VB Express 2010. I'm assuming that the database was
created with a 64 bit machine, if that matters.

I gave my computer a name but for some reason, localhost has my pc name differently:
MyComputerName-PC\MyComputerName

As you can see, my computer name is listed twice with -PC after the first one and
a backward slash after that.

I wonder if SQL can read and understand the minus sign and the backward slash?

Do you think that i need to change my pc name or try to change the name in
SQL Server Configuration Manager to just my pc name?

Last edited by VB_Alien; 04-30-2012 at 05:43 AM.
Reply With Quote
  #54  
Old 04-30-2012, 08:00 AM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is online now
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 1,908
Default

Do you have Microsoft SQL Server installed on your local PC? If so is it the full SQL Server product or is it SQL Express?

When SQL was installed did you go with the defaults during the installation or did you give the instance you were installing a specific name?

If you have the SQL management tools installed can you access the AdventureWorks database via them? If so what user are you logging in to access the DB through the management tools?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #55  
Old 04-30-2012, 05:28 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

I don't have any passwords at all set in the server management app.
I installed the 2012 version of ms sql server express, since it was
free. I know that when i was installing it, i tried giving it a name and
password but it was giving me so much trouble doing that, that i went
with the default install, instead

I did discover that northwind and adventureworks db's were not installed
in the sql express folder, where the master db is, so i just copied and pasted
both of them into that folder. Now, the code above is saying that log-in failed
but at least it sees the database now. I moved one inch with a mile to go yet. lol

Oh. And there is no user name in the server management app. It's a blank textbox.
I do, how-ever have what appears to be a password in the 2 password boxes but
i don't think i put in any password.

I have this program that checks my server for passwords and it is saying that
i don't have any passwords.

I'm currently running with the built in account, so i don't think it's using a password
anyway, but i could be wrong.

Last edited by VB_Alien; 04-30-2012 at 05:34 PM.
Reply With Quote
  #56  
Old 05-01-2012, 03:38 AM
DrPunk's Avatar
DrPunk DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

Copying the files isn't enough. You need to tell the database server about the databases.

In the Management Studio, in the Object Explorer, right-click the Database's folder and choose Attach. Attach allows you to add existing databases to the server. Under Datbases to Attach click the Add button. Browse to wherever the database file is you want to attach and click OK, then click OK in the Attach Database window.

That should then add the database to the server. Expand the Database's folder and you should have a database name in there. Expand that database and you should be able to see the Tables and everything else associated with that database.

Whatever that name is, that's what your initialcatalog in the connectionstring wants to be. You won't need to specify the filename of the database.

If you can connect to the database server using management studio then your program should be able to connect to it (if the log in window in management studio is set to Windows Authentication then you won't have to specify a username or password in your connectionstring).
__________________
There are no computers in heaven!

Last edited by DrPunk; 05-01-2012 at 03:46 AM.
Reply With Quote
  #57  
Old 05-01-2012, 07:53 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

In my server management application, there is no object browser, so
i assume that you meant the object browser, inside my VB program.

Yes, that is a choice but right now i'm concentrating on my Access
database. I having temporarily given up on sql. I'll give that one
another shot after i finish my nearly done access program.

My access project is coming along really good but i have stumbled onto
a problem that i can't figure out.

When i'm writing information into a record field, i'm writing it, directly to
a datagridview. That part works great. The problem i'm having is when
i want to save an image in a cell. The image saves alright but it saves it
in the wrong row. If i'm on the first row and save a picture, the picture gets
saved in the second row, where i haven't even put any information into it
yet.

I thought that just by selecting the cell that the picture is to be saved to, it
would automatically be saved in that cell, but it's not.

I even set the datagridview cell to be saved to:
DataGridView1.CurrentCell = DataGridView1(Col, Row)
but that isn't working either. It always saves in the row below the one i
want to save in.

Here's the code for saving the image:
Code:
Dim ms As New MemoryStream
Dim con As New OleDbConnection()
Dim cb As OleDbCommandBuilder



        DataGridView1.CurrentCell = DataGridView1(Col, Row)

        Try
            picImage.Image.Save(ms, picImage.Image.RawFormat)

            Dim arrayImage() As Byte = ms.GetBuffer
            ms.Close() ' Closes the Memory Stream

            Dim strQuery As String = "INSERT INTO Employees(Picture) VALUES(@Picture)"
            Dim strCon As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & Db_Path & ";"

            con.ConnectionString = strCon

            Dim objcommand As New OleDbCommand(strQuery, con)
            With objcommand
                .Parameters.Add(New OleDbParameter("@Picture", SqlDbType.Image)).Value = arrayImage
            End With

            con.Open()

            objcommand.ExecuteNonQuery()

            cb = New OleDbCommandBuilder(da)
            dt = New DataTable


            ' Fill the datatable with the data table
            da.Fill(dt)

            ' Bind the datagrid with the  datatable
            DataGridView1.DataSource = dt

            MessageBox.Show("Image Saved Into the DataBase", "Save Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try

        con.Close()
As you can see, there i nothing telling the code what cell to save the image to.
Can the query string do that?
Reply With Quote
  #58  
Old 05-01-2012, 08:28 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

I don't want to get off coarse here with my previous post
but i tried to do as you ask.

First of all, when you access the object browser, it has nothing
to do with databases. This is all system properties and that's it.

I did go to the database explorer though and although you can't
right click it, just like the object browser, i did open it up and
proceeded to make a new SQL connection with a SQL database,
namely "Northwind".

Once i did that, there is a button there that asks you to test your
connection. I did that and it failed to make a connection.

It's saying that it can't find the server. Is there a way to point
VB to the location of the "Master" database? The master db
is the server and for some reason, nothing will connect to it,
not even VB.

At least i now know that it wasn't anything that i did or didn't
do. This is a VB problem...
Reply With Quote
  #59  
Old 05-01-2012, 10:37 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 806
Default

OK. It was a VB 2010 setup problem. I already had the 2005 and 2008 versions
installed before i installed 2010. Not to long ago, i uninstalled 05 and 08 because
i only wanted to work with one version only of VB.

Uninstalling wasn't the problem though. It has something to do with the framework
that everything runs from. If someone has the 08 version and then installed the 2010
version, both versions would not make a connect to a sql database, or so that is what
i read online from other with the same problem.

What this means is that you have to uninstalled everything and start fresh again, in order
to get make a connection to a sql database with VB. Just uninstalling from the control
panel isn't good enough though. Doing it that way, still leaves behind artifacts of previous
versions, all around the hard drive.

I had to go to MS and download VS2010_Uninstall-RTM.ENU. Only in english for now.
But this program get rid of every little artifact, including the 4.0 net framework.

After i did that, i reinstalled VB. After that i did want you told me to do and went to
database explorer and attached "Northwind" database to the "Master" database. Then
i went to advanced settings and at the bottom, i found the connection string to use and
bing bang boom, i was connected to "Northwind".

Just like with ADO though, you have to include the full path to the database that you
want to connect to but that's included in the SQL connection string.

It still uses the "AttachDbFilename" in the string to.

So now, this puts me one up. Hopefully i can figure out the rest of it now.
Reply With Quote
  #60  
Old 05-02-2012, 03:40 AM
DrPunk's Avatar
DrPunk DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

Quote:
Originally Posted by VB_Alien View Post
In my server management application, there is no object browser, so
i assume that you meant the object browser, inside my VB program.
No, I mean in SQL Server Management Studio.
__________________
There are no computers in heaven!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->