rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
607 stars 189 forks source link

Cant connect to local database #426

Open velvetsnowman opened 5 years ago

velvetsnowman commented 5 years ago

Environment

Operating System

C:\Users\danie>systeminfo | findstr /C:OS OS Name: Microsoft Windows 10 Home OS Version: 10.0.17134 N/A Build 17134 OS Manufacturer: Microsoft Corporation OS Configuration: Standalone Workstation OS Build Type: Multiprocessor Free BIOS Version: Insyde Corp. V1.19, 24/04/2018

TinyTDS Version and Information

I have 'tiny_tds' version of 0.7.0, in my Gemfile and works (see below)

Description

I have been using Azure Portal recently where I was hosting my databases on their servers. I used Azure just to test their platform as my work uses it, and I wanted to get a feel for it. Now I want to move my database to my local server, which I have done so correctly, fully operational within Microsoft SQL Server Management Studio and can connect to my local server without issue. In order to create a connection, I must create an instance of Tiny TDS Client object, which I had done so successfully when using Azure:

client = TinyTds::Client.new(:dataserver => 'planner.database.windows.net',
                                 :port => 1433,
                                 :database => 'DEV',
                                 :username => 'myusername',
                                 :password => 'mypassword',
                                 :azure => true)

Now for my local server/database on my machine, I use this:

client = TinyTds::Client.new(:dataserver => 'LAPTOP-DF86KL64\DANIELDENHARTOG',
                                 :port => 1433,
                                 :database => 'DEV',
                                 :username => 'dani',
                                 :password => '') <-- 'yes this is an empty string'

I run 'rackup' and, the error I get is:

2019-01-23 22:06:20 - TinyTds::Error - Unable to connect: Adaptive Server is unavailable or does not exist (LAPTOP-DF54JL64\DANIELDENHARTOG):

When i use these params and run rackup:

client = TinyTds::Client.new(:dataserver => 'LAPTOP-DF86KL64\DANIELDENHARTOG',
                                 :port => 1433,
                                 :database => 'DEV',
                                 :username => 'DANIELDENHARTOG',
                                 :password => 'potentialpassword') <-- 'a potential password associated to account if thats my username'

I get errors like this:

TinyTds::Error - Server name not found in configuration files:

Now, I have tried:

Perhaps I need to adjust settings in SSMS? If this may be a username/password issue, theyre reffering to my username which can be found in SSMS? https://imgur.com/a/P8TuRRr I mean, what other username/password would I use? https://imgur.com/a/lYyrarU https://imgur.com/a/tFc49Dl

I hope this is ok to post here, i have been researching this for 5 days now. Thanks

velvet

rosspe commented 5 years ago

I have the same issue

velvetsnowman commented 5 years ago

Any ideas? @tiny_tds , @rosspe

superwagen commented 5 years ago

Me too

rosspe commented 5 years ago

this is what I setup :

require "tiny_tds"

client = TinyTds::Client.new host: '127.0.0.1', port: 1433, database: 'XXBars', username: 'philip', password: 'password'

I think I also changed a setting on the database unhelpfully I can't remember what it was. I am SQLServer authentication rather than windows

rosspe commented 5 years ago

mine works now of course, I forget to say that

superwagen commented 5 years ago

thanks you, I got it to work definig dataserver instead of host and adding _tdsversion: to 8.0, because the server are sql server 2000

velvetsnowman commented 5 years ago

this still does not work for me. i am still in testing and do not want to be paying for online dbs. pls, any help on settings and params to connect to a local db with tiny tds

ogaida commented 3 years ago

for me it looks like tiny_dns uses tcp/ip which is not possible with localdb. so you could use sqlexpress instead, where you can enable tcp/ip. Download: https://www.microsoft.com/en-US/download/details.aspx?id=101064

its free and limited till 10 GB of data. do not forget to activate tcp/ip in sqlexpress by using "sql server configuration manager". it is part of sqlexpress installation package. Look at the screenshot, right click on tcp/ip and configure Port 1433 for ipall.

image

image