Thursday, March 29, 2012
Can't connect after changing IP address
not connect to my local database using ".\MyDBS" notation, howver
"127.0.0.1\MyDBS" works. Also, both work after restarting the SQL
service.
I am using the query analyzer to test success or failure.
My event logs show nothing and my SQL logs show no errors.
Any ideas on how to debug this further or solve it altogether?
Thank youHi Arron,
Thank you for using the newsgroup and it is my pleasure to help you with
you issue.
From your information, after change the IP, in the Query Analyzer, you
could not connect to my local database using ".\MyDBS" while
"127.0.0.1\MyDBS" works. After you restart the SQL Server service, this
problem do not happen, right?
I want to go forward with some more information since I could not
re-produce this problem on my computer. Do you encouter any error message
when using ".\MYDBS" that indicating you cannot connect to the server? How
about using the '(local)'? If you do not restart the SQL Server service,
it will not connect to the server even after some time? If you connect from
another machine by Query Analyer, do you meet the same problem?
When a SQL Server is started, it will listen to the IP and the port of when
it is started. So, when you change the IP address, you should restart the
SQL Server service and then it will listen to the new IP address. For the
localhost and the 127.0.0.1 will be the local machine.
You could refer to the following article for the name resolution:
http://www.microsoft.com/technet/pr.../ewsa/ewsach08.
mspx#XSLTsection124121120120
Hope this helps. If you still have questions, please feel free to post
message here and I am glad to help.
Thanks.
Sincerely Yours
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.|||Hi Aaron,
I am reviewing you post and since we have not heard from you for some time
in the newsgroup, I wonder if you got answer from my answer. For any
question, please post your message here and we are glad to help.
Thanks.
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.
Tuesday, March 27, 2012
Can't Call Stored Procedure in SqlFunction
There is a SqlFunction in my SQL Server Project:
[Microsoft.SqlServer.Server.SqlFunction(DataAccess=DataAccessKind.Read)]
public static SqlBoolean GetRelation(SqlGuid ID)
{
using (SqlConnection conn = new SqlConnection("context connection=true"))
{
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM MemberRelation WHERE ID='" + ID + "'", conn);
//SqlCommand cmd = new SqlCommand("EXEC GetMemberRelation '" + ID + "'", conn);
/*SqlCommand cmd = new SqlCommand("GetMemberRelation", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@.ID", SqlDbType.UniqueIdentifier));
cmd.Parameters["@.ID"].Value = ID;*/
using (SqlDataReader sdr = cmd.ExecuteReader())
{
sdr.Read();
//...
sdr.Close();
}
conn.Close();
}
}
When I try to call a stored procedure by using one of the two marked code segments instead of concatenating string in GetRelation, I can deploy the project to my SQL server without problem. But when I call GetRelation from Query Analyzer, I get an error: "Invalid use of side-effecting or time-dependent operator in 'SET ON/OFF' within a function."
What does the error message mean? How could I correct it? Thanks for answering.
The problem is resolved. Just remove the default "SET NOCOUNT ON;" added by SQL 2005 while creating stored procedure, then the SqlFunction will work.|||Does anyone know of another way to fix this? We have alot of stored procedures with "SET NOCOUNT ON" and I would really rather not have to make that change unless we have to.
Thanks,
JD
Bleh... I can't see good way. :) You could make a normal connection instead of using the context connection, but you'll have to deploy your assembly as external-access.
Cheers,
-Isaac
Can't Call Stored Procedure in SqlFunction
There is a SqlFunction in my SQL Server Project:
[Microsoft.SqlServer.Server.SqlFunction(DataAccess=DataAccessKind.Read)]
public static SqlBoolean GetRelation(SqlGuid ID)
{
using (SqlConnection conn = new SqlConnection("context connection=true"))
{
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM MemberRelation WHERE ID='" + ID + "'", conn);
//SqlCommand cmd = new SqlCommand("EXEC GetMemberRelation '" + ID + "'", conn);
/*SqlCommand cmd = new SqlCommand("GetMemberRelation", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@.ID", SqlDbType.UniqueIdentifier));
cmd.Parameters["@.ID"].Value = ID;*/
using (SqlDataReader sdr = cmd.ExecuteReader())
{
sdr.Read();
//...
sdr.Close();
}
conn.Close();
}
}
When I try to call a stored procedure by using one of the two marked code segments instead of concatenating string in GetRelation, I can deploy the project to my SQL server without problem. But when I call GetRelation from Query Analyzer, I get an error: "Invalid use of side-effecting or time-dependent operator in 'SET ON/OFF' within a function."
What does the error message mean? How could I correct it? Thanks for answering.
The problem is resolved. Just remove the default "SET NOCOUNT ON;" added by SQL 2005 while creating stored procedure, then the SqlFunction will work.|||Does anyone know of another way to fix this? We have alot of stored procedures with "SET NOCOUNT ON" and I would really rather not have to make that change unless we have to.
Thanks,
JD
Bleh... I can't see good way. :) You could make a normal connection instead of using the context connection, but you'll have to deploy your assembly as external-access.
Cheers,
-Isaacsql