How to produce a clickable link in SSMS? - sql-server

I am using SQL Server and I created a table:
create table data
(
description nvarchar(100),
url varchar(500)
)
Then I insert data:
INSERT INTO data (description, url)
VALUES ('google', 'https://www.google.com'),
('yahoo', 'https://www.yahoo.com'),
('baidu', 'https://www.baidu.com')
I want to get a clickable url when executing:
select url
from data
where description = 'google'
In other words, when I click the url returned, a chrome will be opened and go to google site.
I found that there is a method but it requires user to click twice.
What should I do?

The one that succeed to me is setting the data type of the url as xml so that it is clickable then you will get a new query window and there if you click the url with CTRL+K then the url will pop in the sql server window. For url the most appropriate data type would Varchar with preferred length but unfortunately that is not clickable within SSMS.
You can check the following URL,
basically you can click in query editor or you can set and there are few more alternatives here,
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8c78549d-0aa2-4fed-acab-51ad11cb59a4/is-url-clickable-somewhere-in-ssms?forum=transactsql

Related

[MS-Access][ODBC] Can't delete an line on a form, ODBC delete on a linked table failed

I have a form that is linked to an ODBC (MS SQLServer), that is displaying a result of a VIEW, when I try to delete a record, I'm invoking a function at VBA level
Form_BeforeDelConfirm(Cancel As Integer, Response As Integer){
If (IsNull(Text104.value) = False) Then
Dim deleteLabel As DAO.QueryDef
Set deleteLabel = CurrentDb.CreateQueryDef("")
deleteLabel.Connect = CurrentDb.TableDefs("KontrollWerte").Connect
If (InStr(QuerySave, "KontrollWerteVIEW") <> 0) Then
deleteLabel.sql = "delete from KontrollWerte_Label where Kontrolle_Label_ID = " & Text104.value
End If
Close
End If
}
Error shown:
[Microsoft][SQL Server Native Client 11.0][SQL Server] View or function 'dbo.KontrollwerteVIEW' is not updatable because the modification affects multiple base tables. (#4450)
This error is okay, as the view is a select with multiple tables.
It seems the function is not called at all, and the "default" delete function of the MS Access is being called, there is a way to say to MS Access don't do the default delete and instead execute my sql statement inside of the Form_BeforeDelConfirm function?
Thanks!
I tried to change when the call of function is called, but no luck.
You have to ensure that the view allows updates.
When you link a table, and it is a view?
The during the creating of the table link, then you will see this prompt:
First, we select the "view" when linking that "view/table"
and note I also checked the Save password option.
Then next we get/see this:
DO NOT skip the above prompt. If you don't select the PK column for that view, then it will be read only.
FYI:
The above prompt to save password, and the above prompt to select the PK when linking to that view?
It DOES NOT appear on re-link, ONLY when adding a new link!!!!
So, that's why I stated to delete the link to sql server (not just re-link and not just re-fresh table link, but Adding for first time are the key instructions here).
So, yes, views are and can be up-datable, but you MUST answer the above prompt during the linking process in Access, or the result is a read-only table.

New column in my table not visible after adding and publishing

I have an existing table => zoo[design] I add to it new column:
zooName nvarchar(50) allow null
Then I updated the server but when i go in zoo[data] and push refresh I can't see the zooName there.
But if I make new Query
select * from zoo
it's display for me the zooName but i can't edit it in the zoo[data]
I closed the project and open it again then it's ok
I don't want to open and close the project every time I need to add new row.
Refresh on your database node from Object Explorer if you are using MSSQL.

SSRS 2012 display Bing map image

I have created sql to retrieve information from our table and create the url for a Bing map. If I take the url from the query and paste it into a browser the map image appears.
Example: https://dev.virtualearth.net/REST/V1/Imagery/Map/Road?mapSize=600,600&mapLayer=TrafficFlow&format=png&pushpin=35.96981750,-85.03747790;64;1&key=xxx
But in SSRS if I use the url as an external image I get the red-X-in-box. No error message but no image either.
I read there should be a way to "enable external images". I've checked the box for the image. Is there another place to change the setting?
I can produce your map without any issues. Follow these instructions and make sure you can reproduce the same results, , then compare to your own report. Hopefully the issue will become apparent.
Create a new Report.
Create a new Dataset called BingMapSample and use the following dataset query, swapping the key for your Bing maps key
-- set up some static values
DECLARE #BingmapKey varchar(256) = 'XxXX-99x-
9XXXXX9XXxxxXXXxXxXxxxxXxXxx9X9XxxX9xxXxXX9xXXx99x9XXxx'
DECLARE #MapSize varchar(10) = '600'
DECLARE #Layer varchar(256) = 'TrafficFlow'
-- stick a few locations in a table, the first one is from your exmaple
DECLARE #mapLocations TABLE (coords varchar(256))
INSERT INTO #mapLocations VALUES
('35.96981750,-85.03747790'),
('50.998647,-0.105406')
-- now build up some urls to use in the report
SELECT
'https://dev.virtualearth.net/REST/V1/Imagery/Map/Road?mapSize=' + #MapSize + ',' + #MapSize
+ '&mapLayer=' + #Layer
+ '&format=png&pushpin=' + ml.coords
+ ';64;1&key=' + #BingmapKey
AS BingMapSampleURL
FROM #mapLocations ml
Now add an image to your report (use a sensible size) and set the following
Source = External
Value = =First(Fields!BingMapSampleURL.Value, "BingMapSample")
If you run the report you should see your map displayed.
To show both maps in a list, do the following
Add a 'List' to your report and set
DataSetName = BingMapSample
Resize the list's only cell to something sensible then inside the list 'cell' insert an image. Set the image properties as follows
Source = External
Value = =Fields!BingMapSampleURL.Value
The final design looked like this... (I shaded the list background just for clarity).
If you run the report you should now also see two more maps, three maps in total.
When I run the report I get this
Hope that helps...

Displaying data from the database on a textbox in the presentation layer. Three tier architecture

Create procedure sp_getTotal
#InvoiceID varchar(50)
As
Begin
(Select Invoice.Total
from Invoice
where Invoice.InvoiceID = #InvoiceID)
End
I have created the above procedure to get the "total" from Invoice table in my database on SQL Server. I need to make this value be displayed on a textbox in the presentation layer on button click of an app created using three tier architecture. The procedure has already been passed into the Data Access Layer and the Business Logic Layer.
How do I code the button for this?
Thanks in advance for replies
Well, basically on the presentation layer, create a button, hook-up its click event.
Then, on the button click event, call your middle tier method.
This method will basically only call your data tier, which contacts the database and runs the stored procedure and maps the return to a proper int.
On the way back to the presentation, simply assign the returned value to the desired text box...
On the button click:
MyMiddleTierController lvl2 = new MyMiddleTierController();
myTextBox.Text = lvl2.GetInvoice("12345");
On the data tier:
//Open sql connection
//Map stored proc command to SqlCommand
using(SqlDataReader reader = myCommand.ExecuteReader()){
if(reader.Read())
return reader[0];
}

SQL Server CE database and ADO.Net Entity Framework - data not saving

I have a SQL Server CE database file and I have ADO.NET Entity Framework object named History. I perform the following to get the latest ID:
var historyid = (from id in db.Histories // Get the current highest history Id
select (Int32?)(id.Id)).Max();
HistoryID = Convert.ToInt32(historyid);
if (HistoryID == 0) // No current record exists
{
HistoryID = 1; // Set the starter history Id
}
(Not the best way, but it is just to test).
This works well and returns the correct value (If I manually enter an ID of 1, it returns 1, same with 2 etc..)
The issue is with the following code:
History history = new History();
history.Id = 1;
history.SoftwareInstalled = "test";
db.AddToHistories(history);
db.SaveChanges();
The above works and runs through fine, but the changes are not saved to the database! Why is this?
Here is my db variable: dbDeSluggerEntities db = new dbDeSluggerEntities();
Thanks.
Edit: Here is an update: I noticed when I run the program and debug it, it shows that a history has been created and inserted and also gives an error of the primary key already existing, this happens each time I run the application (over and over). However, when I go to server explorer and right click the db and select 'Show Table Data' it shows no data.. When the program is run again, there is no primary key error or history's showing in the debug!
I was having exactly the same problem. By default the database is copied into your bin folder when you run the app and that is used.
My solution was to go into the properties of the db and set it to never copy and to put a full file path to the database in the connection string in the apps config file.

Resources