Making a SQL Server connection in Visual Studio 2008 for smart device application - vb.net

I am tyring to create a scanner application and this requires going into my database and fetching a upc code. However I don't know how to accomplish this in visual studio. Essentially when a person clicks a button a database connection should open from the smart device which will allow the user to see the price of an item. However I was struggling trying to create a a database connection so I tried doing it by my odbc driver which is how I use it for my access programs. This worked and I can see all my tables on my server explorer. However I don't know if I have to explicitly establish a connection pragmatically as well in order to run a select statement....
I forgot to mention I decided to go with an ODBC connection because when I tried sing Microsoft Sql Server (SQLCLient) I got an error saying "The server version is not supported only servers up to Microsoft Sql Server 2005 are supported"
So I decided to go with the odbc driver but I don't even know if using an odbc driver will work while using the application on the scanner device
I haven't programming with VS nor vb.net so this is all pretty new to me, so any pointers at all help

Related

How to connect to a SQL Server from an m1 chip macbook

I am working on a project with a friend and he has deployed a SQL Server database. He uses a PC and can access the database using Microsoft SQL Server Management Studio (SSMS).
However I have a Macbook with an M1 chip and so I cannot use SSMS and need to figure out which SQL Server application I want.
It seems like the way to go is Microsoft Azure Data Studio. I cannot figure out how to connect properly, I have looked at several solutions posted online which all say to download docker, download the latest SQL Server image, use SQL edge, run SQL Server in a container and then open Azure and connect.
One caveat is that all these tutorials end with creating a SQL Server on the local host rather than connecting to an existing one.
In Azure, after entering server id, username and password, there is a green dot on the label of the DB on the left drop down menu, indicating that the connection to the DB was successful. However whenever I try to view the DB's from the drop down it loads and then errors:
Object Explorer task didn't complete within 45 seconds
and I cannot run any basic queries either.
At this point I don't care what IDE I use as long as it works. Any advice is much appreciated. It seems like this task should be super easy but has given me such a hard time and we cannot continue working on the project until I get access.
Anyways, thanks again in advance! and lmk if there's any other info I should provide.
Tried using docker with Azure Data Studio and my results were the same as when I only used Azure.
You'll want to use Azure Data Studio.
You don't need Docker at all to meet your goals. Those tutorials were in regards to running your own SQL Server instance on a Mac. You're trying to connect to an existing instance.
As mentioned in the comments, where is the existing SQL Server instance located?...is it on a server that's part of a domain. Is your Mac part of that same domain? It sounds like you're getting some kind of timeout issue or some sort of authentication issue. So this is more of an infrastructure question.
Once connected to the SQL Server instance in Azure Data Studio, what happens if you just open a blank worksheet and run the query SELECT ##SERVERNAME?

MS Access Pass-Through DSN-less query: what is wrong with my connection string?

I've done this before and am following my own example but it's not working. I have a simple pass-through query in MS Access 2013. It is supposed to query (just a "SELECT * from " query for now) a Microsoft SQL Server using a DNS-less connection string. The server is set up for mixed authentication. I can use the Linked Table Manager and open tables from this same MS Access file. I can ping the servername from a command prompt. The client computer is Windows 7 and has the Microsoft SQL Server 2012 Native Client installed. I suspect something's up with my connection string, but I can't see it.
In the "ODBC Connect Str" property of my Pass-Through query I have:
ODBC;DRIVER=SQL Server;SERVER=SERVERNAME;Trusted_Connection=Yes;DATABASE=<dbname>
When I try and View the query I get
ODBC--connection to 'SQL ServerSERVERNAME' failed.
EDIT: Yes, I have tables linked to the same SQL server via Linked Table Manager. I also have an ODBC connection to the same server, and it tests just fine (using the "Test Connection" button in the ODBC connection wizard.
Yes, my suspicion is that it's something to do with the connection string. I just don't see the problem and am hoping someone has a better eye than I do, or has some experience with this that will help produce an idea.
The server is Microsoft SQL Server 2017 running on Windows Server 2016.
I'm hoping my edits can cause this question to be unlocked again.
See my comment below for tips and my ultimate answer, in case you are struggling with this also.

How can I monitor all SQL commands that go through a ODBC User DSN

How can I monitor all SQL commands that go through a ODBC User DSN?
the datasource is using the SQL Server native Client 10.0 driver.
I have an access app with hundreds of confusingly complex reports. Over the last 3 years We have ported the app to ColdFusion and MS Sql server and one of the reports has some inconsistencies with the access version of the app.
I've tried tracing the code through in the access app to discern exactly what is going on but I've been unable to figure it out. The access app uses an ODBC user DSN with the SQL Server native Client 10.0 driver. Is there some way I can monitor the datasource and see all the sql commands that are executed over that channel?
Setup a SQL Server profile trace and capture the command being executed on the server. I assume you are using MSSQL as the backend?
https://expressprofiler.codeplex.com
It's free profiler in case you use SQL Server Express version.

Connecting to SQL Server 2008 Express from VB 2008 Express

I'm using VB 2008 Express for our College Project. I'm also running SQL Server 2008 Express and have installed SQL Server Management Studio and used it to create my database.
Both software have been installed and running locally. I'm trying to connect to the database from VB 2008 Express. Database connection wizard have 3 options:
connecting to Access db
connecting to SQL Server 3.5 compact db and
connecting to SQL Server db file.
There are no problems connecting to the first two but when I try to connect to my SQL server DB file (.mdf) it throws the following error ("Unable to open the physical file .... Operating system error 32:(failed to retrieve text for this error. reason:1815.......an attempt to attach an auto-named database for file ...... .mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share")
I appreciate if anyone who had the same experience and overcome the problem could point me in the right direction.
Thanks very much.
Little Critter.
You need to detach your database from the server. Since you created the file there it is already running on the SQL Express server. Operating System Error 32 is a sharing violation and it means that the file is in use.
Try this:
Open Sql Express 2008 Managment Studio and find your database in the Object Explorer tree.
Right click on your database, choose tasks, and then select "Detach"
When the "Detach Database" dialog appears, select the checkbox that says "Drop Connections"
Click ok.
Your database should detach from the database server. Now the server will no longer bring that database up automatically and you should be able to get exclusive access to it.
Note that if you want to make more edits to the MDF you will have to reattach the database or you will need to use the tools built into VB 2008 Express. Because of this most people would choose to leave the database attached and not run it as a "User Instance". Check out this link for alternative ways to get to your data: How to: Access and Initialize Server Explorer/Database Explorer.
Anyway, you may have your reasons for setting it up this way. The steps outlined above should fix you up. Good luck with your project!

Can't establish SQL Server connection from VS 2008

I am sorry if this sounds like a silly question, but I have googled for a while for a solution and no success. I am trying to establish a connection from VS 2008 to SQL Server. I am trying to use an user that my web application has been successfuly using to access the database from in its connection string. But when doing it from VS 2008, it tells me "Login failed for use 'xxxxxx'". I am currently in the "Add Connection" window. I have chosen the datasource and server name, fulfilled username and password for SQL Server Authentication. Do I have to set specific permissions for this user? Do I need to allow a VS 2008 user in SQL Server? Thanks.
I have found the solution for this problem. My Visual Studio would pull automatically something like MACHINENAME\SQLEXPRESS. As it was pulled automatically, I did not bother taking a closer look at it. I finally realized the connection string that worked for me in my other application was .\SQLESXPRESS. When I entered it in Visual Studio, it did work. Thank you all for the help.
Do you have SQL Server Management Studio Express Installed? if so try connecting as the same user through that interface. This will isolate your problem a bit.
With Visual Studio, you're connecting through a "remote" connection, even though they're on the same machine. With Server Management Studio, you're connecting through a named pipe probably. You need to change the SQL configuration so that it allows remote connections. Here are instructions for how to do it.
You can test your SQL connection by connecting using LINQPad, Often find this solves problems with connections to new SQL Server instances at my workplace.
http://www.linqpad.net/
Are you trying to specify the username and password to connect with in the connection string - ALA:
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
This actually uses SQL Authentication, not Integrated (Windows) authentication. What you might be looking for is this:
Data Source=myServerAddress;Initial Catalog=myDataBase;Trusted_Connection=True;
This would log into the database as the use running Visual Studio. Notice that the username/password aren't specified here - it uses the current Windows identity - in your case, that's the user running Visual Studio.