Thursday, March 8, 2012
change charset
Browse IE can see the contents changed.
But when I view the source, the charset of data does not changed.
Can I change the charset of the data ?This has nothing to do with SQL Server, so you will
probably have better luck in another newsgroup, but
here's a guess:
When you view source, the meta tags will not be
interpreted, since the point of viewing source is to
do no interpretation, and just see the underlying
page description.
The character set used to display the page source is
most likely determined by your operating system
character set.
You might be able to find a text editor that allows
you to specify the code page of the source text.
Steve Kass
Drew University
Win wrote:
>I changed the charset in a web page using (<META> ).
>Browse IE can see the contents changed.
>But when I view the source, the charset of data does not changed.
>Can I change the charset of the data ?
>
>
>
>
Saturday, February 25, 2012
certification question
on page 27, it says:
"INSTEAD OF triggers are useful when a DML operation is unsuccessful."
I think this is nonsense. Any comments?Ford Desperado (ford_desperado@.yahoo.com) writes:
> I am reading Administering SQL Server, a study guide for 70-228
> on page 27, it says:
> "INSTEAD OF triggers are useful when a DML operation is unsuccessful."
> I think this is nonsense. Any comments?
Without any context at all, the sentence certainly looks funny. It reminds
of what I once read in a manual from DEC: "Frequently, unexpected errors are
entirely unpredictable."
I guess what they are trying to say is that when you cannot insert, update
or delete directly on a view, because the view does not live up to the
rules, then you can achieve this with an INSTEAD OF trigger.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||>Without any context at all, the sentence certainly looks funny.
well there isn't any more context.
Thanks Erland|||It's certainly a strange comment in the absence of any context, as
Erland says. Another possible explanation might be that if you have to
INSERT data into a table where you know that some data will violate
constraints, an INSTEAD OF trigger could be used to INSERT only the
good data, and flag or log the bad data; if you did a single INSERT,
then it would all be rolled back.
Simon|||One more nonsense:
the book claims that db_denydatawriter " Can deny the write permissions
on any object"
According to BOL, db_denydatawriter Cannot modify any data in any user
table in the database, and BOL seems to be correct
I think the author, Joyjit Mukherjee, screwed it up|||It sounds like he took a guess based on the group name, rather than
look it up in BOL, which would make me wonder about the quality of the
rest of the book. I've seen the official MS Press MCDBA study guides,
and they seem to be quite good, but then I suppose they should be.
Incidentally, sp_dbfixedrolepermission gives quite a detailed (and
accurate) list of each role's permissions - it's a bit clearer than the
comments in BOL.
Simon
Tuesday, February 14, 2012
catch sql command if value doesnt exist
I have a sql command that is loaded on page load that collects information based on the query string. The query string is a random group of numbers and letters. How do I catch it and direct to an error page if the query can not be found in the database?
Thanks!
if you are trying to get some parameters from the querystring then you can use
dim queryvariable as string =request.querystring("variable")
try
dim sqlquery as string
sqlquery="SELECT column_Name from Table_name where variable= "& queryvariable
//use this sqlquery to check whether it returns some rows or not
catch
response.redirect("pageNotFound.aspx")
end try
|||
I'm pretty sure i did all that.
in page load i'm doing
getUserInfo(Request.QueryString["uid"]);
then the method
protected void getUserInfo(string userid) {string selectCmd ="SELECT * from users WHERE ID = @.id";string strConnection = ConfigurationManager.ConnectionStrings["TimeAccountingConnectionString"].ConnectionString; SqlConnection myConnection =new SqlConnection(strConnection); SqlCommand myCommand =new SqlCommand(selectCmd, myConnection); myCommand.Parameters.Add(new SqlParameter("@.id", SqlDbType.VarChar, 10)); myCommand.Parameters["@.id"].Value = userid;try { myConnection.Open(); SqlDataReader datareader = myCommand.ExecuteReader();while (datareader.Read()) { lblFirstName.Text = datareader["firstname"].ToString(); lblLastName.Text = datareader["lastname"].ToString(); lblTeam.Text = datareader["team"].ToString(); lblOffice.Text = datareader["office"].ToString(); } datareader.Close(); myConnection.Close(); }catch { Response.Redirect("~/error.aspx"); }|||
any ideas?
|||In your code you aren't checking if the datareader actually contains any data or not, so if no records are being returned nothing happens. 1 simple way to do it is:
1. Declare a boolean variable at the top initialized to False: boolean bolUserFound = False
2. Inside the while loop set the value to true: bolUserFound = True
3. After you close the connection evaluate the variable and if it's still false you know no records were found and you need to redirect to your error page:
if (bolUserFound = False) {
Response.Redirect("~/error.aspx");
}
|||perfect!
Exactly what i needed...