Cant find my SQL database to make Connection
I'm using VB.NET 2010, and Microsoft SQL Server 08 Express.
I've never done a data bound project before so forgive me if I have no clue what I'm doing.
I was following this video tutorial series:
http://www.youtube.com/watch?v=7Qemt...eature=related
http://www.youtube.com/watch?v=qUesXr6rjkQ&NR=1
http://www.youtube.com/watch?v=meRCO_bW-8s&NR=1
http://www.youtube.com/watch?v=h5isqAgSHgQ&NR=1
http://www.youtube.com/watch?v=BVS2_...eature=related
http://www.youtube.com/watch?v=Zwv1u3KPUmQ&NR=1
I was able to create a database on my 'local' server (that I set up when I installed the program???)
however, I cannot figure out how to link to it in my vb project. I've gone into add datasource -> Database -> Dataset -> and tried all the options here. I can't detect any databases, and I don't know how to search for one.
I don't see how this can be that complicated... I'm assuming I probably have something set wrong with the database, but I have no idea where to look. even if this isn't totally appropriate for the .net forum, I have no idea where else to ask.. (I didn't see a dedicated database forum)
Any help would be appreciated.
Re: Cant find my SQL database to make Connection
I see a whole bunch of video tutorials there but no indication that you've actually read anything. There's a lot to be said for actually reading instructions.
Anyway, there are two ways to work with SQL Server Express in VB. First, you can open Management Studio Express and create a database that is permanently attached to your instance. Second, you can add a data file directly to your project and attach it on demand. It sounds like you have gone the first option, but it's by no means certain.
When you get to the step in the wizard where you Choose Your Data Connection, the drop-down list will show all the connections listed in the Database Explorer window. If you already have a connection there to your database, select it. If you don't, click the New Connection button. For the Data Source, you need to select Microsoft SQL Server for a permanently attached database. If it's not already selected, click the Change button and select it. You then select or enter your server/instance name, which should be ".\SQLEXPRESS". You can also replace the dot with "(local)" or your machine name. You'll probably want to stick with Windows Authentication and then you can select your database.
Re: Cant find my SQL database to make Connection
Lets clarify.
I've never done any databound programming before. I've done a bunch of reading, but I rarely understand it. I linked to that video tutorial because it was one of the few which I could easily understand.
My problem with how most tutorials / how tos is that they either tell you what to do, or how to do it, but never both. and I mean that in, they'll either tell you the concept, and not the actual steps, which doesn't tell you much unless you already know the program or system. or they tell you the steps, or some code, without explaining how it works, keeping from you expanding upon it of your own accord.
That specific tutoiral, although not the most specific on HOW a database works, shows clearly how to create one, link to it, and then manipulate it via code.
I've looked into my problem a bit more since I first posted this, and I have a few more details.
When I go into VB, under add data source, he says to make sure you set it to 'Microsoft SQL Server', however that option is not available to me. The only options I have are:
Microsoft Access Database File
Microsoft SQL Server Compact 3.5
Microsoft SQL Server Database File
They sound the same, but instead of prompting to connect to a server, they ask me for a database File...
I'm not sure what to do from here. To me, it sounds like I might have VS not configured correctly, or maybe didn't check a checkbox of some kind when installing SQL.
Maybe that will shed some light on the situation.
So in total I:
Used SQL Server Management Studio to Connect to my local Server
Created a Database
Created a Table
Opened up VS (vb.net 2010 express)
Clicked 'Add a Data Source'
Chose Database -> Next
Dataset -> Next
New Connection
Change Data Source - No option for 'Microsoft SQL Server'
Re: Cant find my SQL database to make Connection
I don't have VB Express installed here to check but I have an inkling that VB Express can only connect to local data files and not database servers. It's a while since I used it and I can't recall, but what you've posted supports that. In that case, you will have to add a data file to your project and use that, which would be the Microsoft SQL Server Database File option. You can always change the connection string later, either during development or when deploying, if you so desire.
To add a Server-based Database to your project, use the Solution Explorer or the Project Menu and select the Add New Item option.
Re: Cant find my SQL database to make Connection
No VB Express can connect to a SQL Server with out any problems. What does the connection string look like? When you install SQL Server Express it is as a named instance only so for an installation on a local machine that would be ./SQLServerExpress
Re: Cant find my SQL database to make Connection
Quote:
Originally Posted by
GaryMazzone
No VB Express can connect to a SQL Server with out any problems.
That's good to know
Quote:
What does the connection string look like? When you install SQL Server Express it is as a named instance only so for an installation on a local machine that would be ./SQLServerExpress
I don't know what this means... I'm assuming I find that in the SQL Server config?
I took some screenshots of SQL Connection and the VB Database wizard. Maybe they'll hold a clue.
http://img836.imageshack.us/img836/3899/sqlinfo.png
The next image is REALLY BIG, so I'm just going to link to it instead.
http://img690.imageshack.us/img690/5...rewhattodo.png
The thing is I don't know what to ask or what to say. That's one of the biggest problems with learning something from scratch on your own. you just don't know what to ask.
Re: Cant find my SQL database to make Connection
Did you install SQL Server (the full thing i.e. Developer) or did you install SQL Server Express (this is the free version of SQL Server). This will make a difference in what the connection string will look like.
The actual Instance name if installing SQL Server Express is (the machine name\SQLExpress). So if connecting to a local instance of SQL Server Express the connection string will be:
Data Source=.\SQLExpress;Initial Catalog=someDatabase to connect to goes here;Integrated Security=SSPI;
Re: Cant find my SQL database to make Connection
The problem is, that I don't have the option to enter a data source. VB.NET only lets me enter a 'database file' of one of the three types shown in the picture. In the tutorial I was following, and from your posts, I should be able to enter a data source such as you suggested, but I don't even know where to put it.
It seems like it wouldn't be as hard to find the data string as it would be to find where to put it.. which is what I think the main problem is. does that make any sense?
like you said, it should be .\SQLExpress; ...
but where should I put that?
Re: Cant find my SQL database to make Connection
I never use the wizards. Do it all in code.
I have an example you can look at here:
http://dl.dropbox.com/u/4554150/SMAAuctions.zip
Look into that and I will see if I can explain things as you work though them.
Re: Cant find my SQL database to make Connection
I almost always run code that I'm given before I look at it too hard, because if it doesn't run, then what's the point of looking at it. Since you've linked me to it after hearing my blight (rather than a search engine throwing it in my face) I'll go into more detail.
I tried to run the program, and I get the error:
Error while trying to run project: Unable to start debugging.
The components for the 64-bit debugger are not registered. Please repair your Visual Studio 2008 Remote Debugger installation via 'Add or Remove Programs' in Control Panel.
Is this to be expected? Meaning, I should only look at certain parts of the code (because other parts might be reliant on your system configuration, and thus won't allow the program to run), or is this unexpected and there's an actual problem with my configuration.
It sounds stupid, but when you're used to dealing with simple programming (everything that I've ever done with programming I could still do in VB3, where I started) When you come to a problem dealing with something you've never seen before, you don't know where to begin.
So anyways, I'm assuming I can't run the program in its entirety because of some dependancy... What part in specific should I look at for the database access code... I'm assuming SQLServers.vb, and I'm looking at that now, but I still want to know if the error is expected or not.
Re: Cant find my SQL database to make Connection
No... Are you running a 64 bit system? If so there might be an issue with the section that will link and open an Excel spreadsheet (it is using 32 bit drivers for excel).....
I would just look at the code behind the forms to start with.
Re: Cant find my SQL database to make Connection
Does it matter that I don't have excel? -derp
I was looking at some code in the codebank, which I might be able to use, but it needs the connection string, which now that I need it, I don't know what it is or where to find it.
Any help in that regard?
Re: Cant find my SQL database to make Connection
Look at the code behind my forms. It is in there. There is a class module that will build the connection string and a set of functions (procs) in there that return,delete,insert or update data data
Re: Cant find my SQL database to make Connection
If you want to use the wizard then just do as I suggested. Add a database to your project. You can then simply change the connection string later. When Gary says that VB Express can connect to any database, that is misleading. An app written using VB Express can connect to any database, but the VB Express IDE cannot.
Re: Cant find my SQL database to make Connection
Quote:
Originally Posted by
jmcilhinney
If you want to use the wizard then just do as I suggested. Add a database to your project. You can then simply change the connection string later. When Gary says that VB Express can connect to any database, that is misleading. An app written using VB Express can connect to any database, but the VB Express IDE cannot.
That my friend is an extremely useful insight... I'll do some testing later tonight (not late enough for me just yet)