|
I am writing an update statement an executing it with an ExecuteNonQuery();
I am updating customer names (first and last concatenated) but I seem to be
having trouble with names like Sally O'Hara. The single quote I believe is the
problem because names without it update just fine. I tried to use the ascii value
but that puts 2 single quotes in the data base. I could use some help generating
the customer name string.
Sample code
"UPDATE Appointments SET Customer_Name" + " = '" + customername + "'" + " WHERE AppDate = " + "'" + lappt_date + "'";
Any help would be appreciated.
Thanks for the Help
NewTuCsharp
|
|
|
|
|
It is better to use stored procedures that accept the arguments
and update them in the table.
Regards,
Arun Kumar.A
|
|
|
|
|
You should either use stored procedures or parameterized queries. Both not only avoid problems like this, but also protect against sql injection attacks. See Colin Mackay's excellent article[^] on this subject for further info.
|
|
|
|
|
Rob Graham wrote: protect against sql injection attacks. See Colin Mackay's excellent article[^] on this subject for further info
Darn you beat me to it :->
|
|
|
|
|
I tried to run a DTA Scalar value that returned SCOPE_IDENTITY, and cast it to an Int. However it fell over with an invalid cast exception, on closer inspection, it returned a Decimal.
I looked up on google the solution was to cast the identity as an int in the SQL as follows:
SELECT CAST(SCOPE_IDENTITY() AS INT)
This however simply returns "1" all the time. (Previously the Decimal was the correct value)
Could anyone shed any light on this?
Cheers
Tristan
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Damn DataAdapters reset the Scalar / Non Query flag when you edit the command text.
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
how to store msword file in sql table please help me
raghun
|
|
|
|
|
If it is SQL Server 2000 then in an image column. If it is SQL Server 2005 in a varbinary(max) column.
|
|
|
|
|
You can use blob type for storing files in sql table
|
|
|
|
|
I am trying to create a table containing a varbinary(max) data type. The max key-word is specified in BOL but it also indicates I should done a sp_tableoption with one of the parameter values "large value types out of row".
This is not working as the value does not exists.
I will appreciate some guidence on how to enable this data type.
|
|
|
|
|
varbinary(max) is new in SQL Server 2005. If your server is older (SQL Server 7.0 or 2000) the nearest equivalent is the image data type.
To check what version the server is, run the query SELECT @@VERSION . SQL Server 2000 is version 8.0, SQL Server 2005 is 9.0.
|
|
|
|
|
is it possable to sync two SQL express servers nightly? I only need to sync one database.
my first thought that might work in my situation is writing a program that shuts down SQL then copies the database to remote location that only needs read access to the data then starting SQL services again.
three things i don't really like, the fact that the remote users could not change the data in the case that they need too and would require a catch if one of the servers were down. if there is a supported way to achive this i would rather do that.
|
|
|
|
|
I doubt what you want is possible with the Express edition. You are asking for functionality that is normally required by a business or enterprise.
|
|
|
|
|
I understand that but it does not make sense to spend 10K on something that only 4 users use there is no ROI on that. I know I can write vb script that would do waht I described above but that could open up other issues. and does not support my goal of having the database editable, even though it is not a requirement.
|
|
|
|
|
Planker wrote: it does not make sense to spend 10K on something that only 4 users use there is no ROI on that
Hear you on that.
Planker wrote: my first thought that might work in my situation is writing a program that shuts down SQL then copies
Writing a program to sync both of them wouldn't be that hard, and shutting down SQL wouldn't be necessary...
|
|
|
|
|
Planker wrote: is it possable to sync two SQL express servers nightly? I only need to sync one database.
Huh? Why?
"We are all repositories for genetically-encoded information that we're all spreading back and forth amongst each other, all the time. We're just lousy with information."
- Neal Stephenson
|
|
|
|
|
I have an application that I feel is poorly written, The business edition uses their database format that is not SQL that I need to run either across a WAN(NOT POSSIBLE - they load most of the database when the program opens, takes 5 - 10 mins for the program to open, the users are to stupid not to click on the program again causing it to run even slower, and eat bandwidth on my WAN) or have some sort of replication between the two sites. the Vendor told me to buy their enterprise version and I could run it on SQL express to do the job. from what I know and everything I have read SQL Express does not support replication. So at this point my solution is to get the Enterprise version and do a nightly copy of the data across the WAN, the users at the remote site more or less just need to be able to review the data to make sure someone is doing their job. I feel this is not a complete solution and would like to find a way to replicate the data with out spending 10K on SQL Server so two users have full access to this data.
If anyone has any suggestions I am all ears.
|
|
|
|
|
Planker wrote: I have an application that I feel is poorly written
From the sounds of the rest of your post, it really sounds like it needs to be redesigned. It shouldn't have to load most of the database in one shot per user. You can take it to the meeting table that the system needs to be improved for the better. If they agree, then the ball is in your court to do pretty much whatever you want then
|
|
|
|
|
I have the following query that works, however; I need add another field "client_id" that I need to tie to client name in another table.
I can't even add the client_id from the job_tickets table with this error:
"select coMsg 8120, Level 16, State 1, Line 1
Column 'job_ticket.CLIENT_ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."
I need to display the "client_name" feild from "Clients" table that based off of dbo.job_tickets.client_id...I can do another inner join in the below starement? How do I achieve this?
This works....I just to add the aforementioned
select count(job_ticket_id) as 'Total',
problem_type.problem_type_name 'Problem Type' from job_ticket inner join problem_type on dbo.problem_type.problem_type_id =
job_ticket.problem_type_id where
report_date between '1/01/2007' and '1/31/2007'
group by problem_type.PROBLEM_TYPE_NAME
any help is greatly appreciated.
Regards,
Hulicat
|
|
|
|
|
Hulicat wrote: Column 'job_ticket.CLIENT_ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."
Then add the column to the GROUP BY clause, just like the error message suggested you do.
|
|
|
|
|
Right I know that would seem obvious, however; if I group by client_id.
Then I get the same error for "problem_type.PROBLEM_TYPE_NAME"
I did not know you could group by more than one column; I have not seen that
I threw it in and it worked.
~~~Thanks~~~
-- modified at 20:14 Friday 11th May, 2007
Regards,
Hulicat
|
|
|
|
|
Anybody out there, who can help me with what is SSIS in general but brief ? I need this info urgently, I am new to this term, please help me ASAP
|
|
|
|
|
Interview by any chance? Try this Clickety[^]
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
How it is possible to Run (2 or 3)Reports(SSRS) From SSIS With Default Parameters ? Please Help Me Out
Praveen John
Software Engg
|
|
|
|
|
Yes We can call ssrs reports from ssis.First you have to publish your reports on to reports server manager.But dont schedueled It.And In your ssis package you have add one script task and call your ssrs from script task.
|
|
|
|