|
Hai, I have question about SQL database. I'm using C#2005
let's assume I have a database table 'TEST' with field 'myField'
TEST
----------------
Recno | myField
----------------
1 | axcel
2 | áxcel
3 | axcël
4 | axÇel
5 | áxÇèl
----------------
If I fire the command
"SELECT * FROM TEST WHERE TEST.myField LIKE '%axce%'" The query result would be
TEST
----------------
Recno | myField
----------------
1 | axcel
----------------
my Question is :
1. Is there anyway so the query result would contain all of the record instead of first record only?? I assume this has something to do with Localization class in C#. Am I right?
2. If not possible, any suggestion how to make it possible? maybe using Function in SQL Server? I'm barely new to SQL server..
thankz for the information,
if this question goes in wrong forum, please forgive me 1st..
regards
~erwin~
Mail me at erwin@holyknight.us
|
|
|
|
|
The query is returning the expected results. Only one of your five records contains the string pattern 'axce'. The other records contain different characters. You would need to modify your LIKE clause to account for accented characters.
Paul
|
|
|
|
|
wienzzz wrote: 1. Is there anyway so the query result would contain all of the record instead of first record only??
Yes.
wienzzz wrote: I assume this has something to do with Localization class in C#. Am I right?
No.
It is to do with the collation sequence set up in the database. the column is AS (Accent Sensitive)
wienzzz wrote: 2. If not possible, any suggestion how to make it possible? maybe using Function in SQL Server? I'm barely new to SQL server..
When you create the database the collation sequence should be defined as Accent Insensitive (AI). It causes more problems that it is worth to individually define columns as a specific collation.
|
|
|
|
|
further question,
When you create the database the collation sequence should be defined as Accent Insensitive (AI). It causes more problems that it is worth to individually define columns as a specific collation
can I just modify the properties after the database created?
I try to look for those properties and I couldn't find any properties related to that. Or should it be the SQL Server properties? (like in VFP to turn safety on or something like that?)
second, let's assume that I couldn't change it (because I worked on existing database which I'm not able to change the structure), can I called a function to show the field in the view definition?
well, maybe here's simple example (I'm not doing it yet)
SELECT test.myField, myFunct(test.myField) as newfield
FROM test
assume that myFunct is the function to convert all the accented character to normal character.
can it be the solution?
CMIIW
thankz for the information
regards
~erwin~
Mail me at erwin@holyknight.us
|
|
|
|
|
wienzzz wrote: can I just modify the properties after the database created?
You can modify each individual column. But it is best that it is done at database creation time - or server install time - because it can get in a complete mess if collation sequences are mixed between various columns.
|
|
|
|
|
i create new table and have feild from type image and allow null
in my program i want to ck if this field is fill or empity ??
i use c# ,,,
Palestine
|
|
|
|
|
i try this in my code and its working fine,
ex :
<br />
byte[] img = (searchContact["Photo"] == DBNull.Value) ? null : (byte[])searchContact["Photo"];<br />
searchContact is my SqlDataReader, Hope this can solve u'r problems
Best Regards,
Tomi
|
|
|
|
|
I've used variants of the following
public static T GetData<T>(IDataReader rdr, string column)
{
if (string.IsNullOrEmpty(column))
throw new ArgumentNullException("column");
if (rdr == null)
throw new ArgumentNullException("rdr");
int pos = rdr.GetOrdinal(column);
T returnValue = (rdr[pos] == DBNull.Value) ? default(T) : (T)rdr[pos];
return returnValue;
}
byte[]img = GetData<byte[]>(reader, "Photo");
string contact = GetData<string>(reader, "Contact"); My apologies if the syntax isn't 100% exact, but I'm typing this out from memory.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi everyone, I am developing one web application using C#.Net. I want to add facility for up loading the video file. When user upload video at that time I WANT TO CONVERT IT INTO WMV FORMAT for that I am using WMcmd.vbs command line WMV converter my complete line is
EXEC master..xp_cmdshell 'CScript.exe D:\setup\WMCmd_20070322\WMCmd.vbs D:\Tarun\project\1.avi D:\Tarun\project\144.wmv -v_mode 1 -v_bitrate 500000 -v_keydist 30 -v_buffer 10000 -v_quality 100 -v_preproc 5 -v_width 320 -v_height 240'
I am trying to run it into sql server and it gives message that Query executed successfully. but on system tray it will display one message like "Microsoft (R) Console Based Script Host stopped working and was closed".
So how can I execute this procedure to convert any format's file to another format's file. from command line only. or suggest me the another WMV converter which can convert movie clip to wmv format from command line. It's very urgent pls if u can then help me.
Thanks.
TarDuk - A Memory Beyond The Life.
|
|
|
|
|
Has anything been written to the event log to indicate what the error might be? Also, have you tried running the command directly to ensure that the format is 100% correct?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
the problem is with vista security i guess i will work well with server 2003. I checked it but it all fine.
|
|
|
|
|
Aah. Vista Security. Preventing you from doing anything. At all. Ever.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi all .
How is it possible to create an automated stored procedure in SQL Server?
Thanks in advance
|
|
|
|
|
You could schedule a SQL job to run the SP at a given time.
Paul
|
|
|
|
|
Set up a scheduled SQL job to do it.
Paul
|
|
|
|
|
Rewriting the SP no to use dynamic SQL should improve performance. SQL Server can't optimize the query by caching an execution plan because it doesn't know what the SQL statement is going to be until run-time. You could do this by putting an IF statement in your code that runs 1 query without filtering when no filtering was passed in, or a query with filtering if it was.
Regarding security, you should consider configuring the SP to only be run by particular user accounts that you know are authorized to run it.
Paul
|
|
|
|
|
AlirezaMaddah wrote: If @FILTER IS NOT NULL
WITH RECOMPILE
That isn't syntactically correct. I meant something like:
IF @FILTER IS NULL BEGIN
-- Query without filtering
END
ELSE BEGIN
-- Query with filtering
END
More code, but at least it's not dynamic SQL.
Paul
|
|
|
|
|
That would work.
You would still have a dynamic query for filtering, but a static one where filtering is not required.
Paul
|
|
|
|
|
The normal thing when doing this is to actually pass the filter criteria as individual items into the procedure and then apply them using something like this:
SELECT item1, item2,...
FROM table1
WHERE (ID = @ID OR @ID IS NULL)
AND (Name = @Name OR @Name IS NULL) This allows the database engine to actually produced a plan.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You can store connection strings as encrypted sections in your config files. In this example, we are encrypting the connectionStrings for the application MyWebApp:
aspnet_regiis -pe "connectionStrings" -app "/MyWebApp"
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Try a where clause like
where id = 7 or id = 42 or id = 12
in other words, write the SQL so it targets all the items you want to update.
Doing this in a proc, you may want to use OpenXML to pass your collection of Ids as an XML document. Then you're likely to create a temporary table with the ids and write a different type of where clause altogether, which checks if the Id is contained in your temporary table.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
1 is obviously more optimised, and if security is a concern at all, 1 also stops the code from having the full table in memory, which is the only point of security I can see.
If you have issues with the server becoming very busy, all the more reason not to clog the network by passing the full contents of the table all the time.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
And querying a DataSet with a View is surely slower than querying data using SQL server when the queries are getting complex (e.g. range queries) or there is a lot of data.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
I work in visual studio.net and because of a virus I had to format drive c and change my win XP and after reinstalling it I change my login name.
After installing visual studio 2005 and sql server 2005 with it , when in the server explorer -> right click on connection -> add connection , I add my last database file (.mdf) and select ‘use windows authentication’ (like when I created this database) .
After runnig my code it shows this exception :
Cannot open database "saraSqlDB" requested by login.
The login failed.
Login failed for user 'HOME\Sara'.
How can I correct this exception?
And if I hadn’t this problem and want to make a setup file from this program if I install this setup file in another computer with another login name and computer name then will it give me this exception or another error like this ? if its so then what can I do ? what about using sql server authentication ?
|
|
|
|
|
I sound like you need to restore the database in SQL and add your login to security in SQL Management Studio.
|
|
|
|