|
Vector7 wrote:
If I am right, there only can one instance of SQL Server at the same time ?
Actually there can be many (I think up to 16, but I'm not sure).
Suppose the server is called SERVER. The default instance is unnamed and thus is accessed with SERVER. The other instances are named (say SQLSRV1) and it's accessed with SERVER\SQLSRV1.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Try to copare your code and the library of connection string.[^]. Learn from it and let me know if it is working or not.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I don't know if it may be the case, but try removing that http:// prefix in the URL. That prefix indicates it is HTTP protocol (for web pages) and the server address is only the IP.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi,
Can someone please help me to format a date in a SQL query coming from SQL Server. I want to format it the way that I like it. Below is what I found in the MSDN library. I want it to display yyyy-mm-dd. Do you this it maybe better to concatenate a string by using YEAR(), MONTH(), and DAY()? Surely there must be a way?
Without century (yy) With century (yyyy) Standard Input/Output**
- 0 or 100 (*) Default mon dd yyyy hh:miAM (or PM)
1 101 USA mm/dd/yy
2 102 ANSI yy.mm.dd
3 103 British/French dd/mm/yy
4 104 German dd.mm.yy
5 105 Italian dd-mm-yy
6 106 - dd mon yy
7 107 - Mon dd, yy
8 108 - hh:mm:ss
- 9 or 109 (*) Default + milliseconds mon dd yyyy hh:mi:ss:mmmAM (or PM)
10 110 USA mm-dd-yy
11 111 JAPAN yy/mm/dd
12 112 ISO yymmdd
- 13 or 113 (*) Europe default + milliseconds dd mon yyyy hh:mm:ss:mmm(24h)
14 114 - hh:mi:ss:mmm(24h)
- 20 or 120 (*) ODBC canonical yyyy-mm-dd hh:mi:ss(24h)
- 21 or 121 (*) ODBC canonical (with milliseconds) yyyy-mm-dd hh:mi:ss.mmm(24h)
- 126(***) ISO8601 yyyy-mm-dd Thh:mm:ss:mmm(no spaces)
- 130* Kuwaiti dd mon yyyy hh:mi:ss:mmmAM
- 131* Kuwaiti dd/mm/yy hh:mi:ss:mmmAM
Thanks
BRENDAN
|
|
|
|
|
SELECT CONVERT(VARCHAR(10),<your datetime value>,20)
|
|
|
|
|
Hi,
I want to query the CASE function in a SQL query.
I have a table field called ContactIsRead. It has a boolean value to determine whether an e-mail has been read or not. When a person open this mail for the first time, it set this field to true, and adds the date to ContactDateRead.
My problem is if the user wants to read this mail again, then I want it to test if the ContactIsRead has been set to true. If not then set it to true and add the current date, if it has been read, then do nothing.
I am working with a normal ASP (not ASP.NET) page that lists all the e-mails as links. Those that have not been read are in bold, while those that have been read are normal text. When a user clicks on the link it take him to a page where he can read it.
I hope it is clear enough. If not, let me know.
Brendan
|
|
|
|
|
Do something like this
select * from
(
select case blah then 1 else 0 end as ContactIsRead from blah blah blah
) mail
where mail.ContactIsRead = 0
You create an alias for the entire query, and then filter on it. The alternative is this:
select case blah then 1 else 0 end as ContactIsRead from blah where (insert same query here that you used in the case statement ).
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
This is a problem better suited for the WHERE clause. A CASE statement would just complicate the matter.
UPDATE
EmailTable
SET
ContactIsRead = 1,
ContactDateRead = DATE()
WHERE
EmailId = 1234 AND
ContactIsRead = 0
In the case where the email had already been read, the UPDATE would result in 0 rows altered.
|
|
|
|
|
I have a Stored Procedure with one input parameter and one
output parameter.
I create a SQLCommand for a Stored Procedure
I add parameter1 with direction input
I add parameter2 with direction output
I add parameter 1 and paramter2 to the Cmd's parameter Collection
I assign an input value to parameter1
I invoke the command's ExecuteReader() and try to
output the result(Parameter2) via response.write
I get a blank?
ps:
1. Procedure works on Query Analyzer
2. At the very end of code I verify two parameter are in
the Paramters collection.
|
|
|
|
|
Try assigning a value to the output parameter and see if it changes. Make it in/out and change the SP to store the incoming value somewhere so you can see if it's getting there OK. Check your spelling.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian:
Thanks for the quick reply. Although I coded as an output while in Query Analyzer, it actually stores it as input/ouput, since while retrieving the output you have to read it into a variable.My spelling must be OK, since no exceptions are raised. I will diagnose some more, but I will get there. I just do not want to reinvent the wheel.
Is 'Command.ExecuteReader' the correct way?
The above is invokation is OK for a stored procedure with one input returning a number of rows of result.
mysorian
|
|
|
|
|
Here's a snippet of my code that does what you're trying to do:
SqlCommand cmd = new SqlCommand("SetTrackThumbNail", Connection);<br />
cmd.CommandType = CommandType.StoredProcedure;<br />
cmd.Parameters.Add("@thumbNailPath", thumbNailPath);<br />
cmd.Parameters.Add("@artistName", artistName);<br />
cmd.Parameters.Add("@trackID", trackID);<br />
cmd.Parameters.Add("@thumbID", -1);<br />
cmd.Parameters["@thumbID"].Direction = ParameterDirection.Output;<br />
<br />
cmd.ExecuteNonQuery();<br />
<br />
return (int) cmd.Parameters["@thumbID"].Value;
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian:
Thanks a lot. Actually, I finally made it work with ExecuteReader()method of the command. What happens actually, is that there is no streaming data and you cannot use the DataReader's Read(). There is nothing to read. However, you may just read out the Output parameter's value. I will try if the ExecuteNonQuery() works as well, as nothing is returned, but everything is contained.
Thanks
jay
|
|
|
|
|
I have a bizzare problem with an SQL query I am trying to build. The problem is, I have a query with a conditional WHERE EXISTS statement that modifies every value in my table, but the SELECT part of the statement returns only the correct, single instance.
This is done in access, in VB, and any help would be greatly appreciated, the queries are listed below.
This select statement returns 1 instance:
SELECT SubCategory.SubCategoryDesc
FROM Category
INNER JOIN SubCategory ON Category.CategoryKey = SubCategory.CategoryKey
WHERE ((Category.CategoryDescription)= GetCurrCategor())
AND ((SubCategory.SubCategoryDesc)= str_Old)
But this update command turns every entry in my table into str_New:
UPDATE SubCategory
SET SubCategory.SubCategoryDesc = str_New
WHERE EXISTS (SELECT SubCategory.SubCategoryDesc
FROM Category
INNER JOIN SubCategory ON Category.CategoryKey = SubCategory.CategoryKey
WHERE ((Category.CategoryDescription)= GetCurrCategor())
AND ((SubCategory.SubCategoryDesc)= str_Old))
Any ideas why this occurs? It's driving me NUTS!
Cheers
Cata
|
|
|
|
|
Well, the exists clause will return true all the time, so every row is updated.
I don't know enough about the Access subvariant of SQL to provide a definitive solution, but I'd have thought that this would work:
UPDATE SubCategory
SET SubCategory.SubCategoryDesc = str_New
FROM Category
INNER JOIN SubCategory ON Category.CategoryKey = SubCategory.CategoryKey
WHERE ((Category.CategoryDescription)= GetCurrCategor())
AND ((SubCategory.SubCategoryDesc)= str_Old)
otherwise, this may work
UPDATE SubCategory
SET SubCategory.SubCategoryDesc = str_New
WHERE SubCategory.CategoryKey IN
(
SELECT SubCategory.CategoryKey
FROM Category
INNER JOIN SubCategory ON Category.CategoryKey = SubCategory.CategoryKey
WHERE ((Category.CategoryDescription)= GetCurrCategor())
AND ((SubCategory.SubCategoryDesc)= str_Old)
)
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Had another crack with those two, but still getting errors.
Type Mismatch on JOIN expression:
str_SQL = "UPDATE SubCategory SET SubCategory.SubCategoryDesc = '" & str_New & "' " _
& "WHERE SubCategory.CategoryKey IN " _
& "(SELECT SubCategory.SubCategoryDesc FROM SubCategory " _
& "INNER JOIN Category ON Category.CategoryKey = SubCategory.CategoryKey " _
& "WHERE ((Category.CategoryDescription)= '" & GetCurrCategory & "') " _
& "AND ((SubCategory.SubCategoryDesc)= '" & str_Old & "'))"
Missing Operator in Query "FROM Category ..... = Subcategory.CategoryKey":
str_SQL = "UPDATE SubCategory " _
& "SET SubCategory.SubCategoryDesc = '" & str_New & "' " _
& "FROM Category " _
& "INNER JOIN SubCategory ON Category.CategoryKey = SubCategory.CategoryKey " _
& "WHERE ((Category.CategoryDescription) = '" & GetCurrCategory & "') " _
& "AND ((SubCategory.SubCategoryDesc)= '" & str_Old & "')"
I've played around with it, but still can't get it to work. Any more ideas?
Cheers
Cata
|
|
|
|
|
Never mind
Thanks for the help, it was pretty much spot on.
Needed to be using SubCategoryKey rather than the CategoryKey. One was specific, the other one was general.
Cheers again
Cata
|
|
|
|
|
No worries, glad to help
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
There is no correlation between the queries in the update statement. No matter which row the SQL Server tests, the EXISTS statement will always resolve to true and therefore, update the row.
I don't think the EXISTS statement is a good solution for this problem (although you could make it work). Try the IN statement:
UPDATE
SubCategory
SET
SubCategory.SubCategoryDesc = str_New
WHERE
SubCategory.SubCategoryDesc IN
(SELECT
SubCategory.SubCategoryDesc
FROM
Category
INNER JOIN
SubCategory
ON Category.CategoryKey = SubCategory.CategoryKey
WHERE
((Category.CategoryDescription)= GetCurrCategor()) AND
((SubCategory.SubCategoryDesc)= str_Old))
|
|
|
|
|
Hi,
In an excel sheet, I have a column (text format), but if I try open this using ODBC driver, this column is open as double data type. Exist any way to change the data type for each column?
I don't want to use a TEXT function from excel, this resolve my problem, but I want another way to chnage it.
Thank you.
ALX
|
|
|
|
|
What am I doing wrong? I do not get any output
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
OleDbConnection1.Open()
OleDbDataAdapter1.SelectCommand.CommandText = "SELECT Location, HotelID FROM Hotel"
OleDbDataAdapter1.SelectCommand.ExecuteNonQuery()
Do
ComboBox1.Items.Add(OleDbDataAdapter1.SelectCommand.CommandText)
Loop
OleDbConnection1.Close()
End Sub
|
|
|
|
|
skicrud wrote:
What am I doing wrong? I do not get any output
Can you tell use, what do you want to do?
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Dont exactly know what you are trying to do here but shouldn't you instead of putting executeNonQuery() put in executeReader()??
I dont know what the do loop is for either??
Try filling a datatable or dataset with you adapter i.e oledbDataAdapter1.fill(myDatatable)
then use your datatable to fill your comboBox ie.
comboBox1.datasource = myDataTable
comboBox1.valueMember = "hotelID"
comboBox1.displayMember = "Location"
ComboBox1.DataBind()
Something like that anyways.
|
|
|
|
|
Hi, guys.
This is an urgent problem that I can only conncet to MSDE 2000(release A, not sp3 or sp3a) from local computer but can not connect to the one running on remote PC. Every time such information is prompted:"SQL Server doesn't exist or access denied."
By the way, the SQL Server service manager running on my PC can start or stop MSDE on both local and remote PC.
Help please. Thanks.
vigorous
|
|
|
|
|
wk_vigorous wrote:
This is an urgent problem that I can only conncet to MSDE 2000(release A, not sp3 or sp3a) from local computer but can not connect to the one running on remote PC
What is the version of your windows operating system? Does your windows install any service pack?
wk_vigorous wrote:
SQL Server doesn't exist or access denied
Try to check the information from here[^] and google.
wk_vigorous wrote:
This is an urgent problem that I can only conncet to MSDE 2000(release A, not sp3 or sp3a) from local computer but can not connect to the one running on remote PC
Try to check the connection library.[^]
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|