|
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.
|
|
|
|
|
the problem is that this is not a full version and is a plugin with visual studio.net 2005 and doesn't have SQL Management Studio . and i dont know how to work with commands on it.
anyway thank you.
|
|
|
|
|
You can restore if you have a backup
RESTORE DATABASE [pubs] FROM DISK = N'C:\SQLBackups\pubs_backup_200709180200.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10
Or if you dont have a backup but havbe the .mdf database file use
CREATE DATABASE [Pubs] ON
( FILENAME = N'D:\SQLDATA\Pubs_Data.mdf' ),
( FILENAME = N'F:\SQLLOGS\Pubs_Log.ldf' )
FOR ATTACH
|
|
|
|
|
thank you
i can restore my .mdf file in server explorer and browse it. and dont have any problem in connecting to sql server but when execute my app. it gives me an exception that the user cant login into this database and with changing user accounts in computer management and adding access rights , the problem still exist.
|
|
|
|
|
It may be that your login is orphaned? you may need to run
sp_change_users_login 'Auto_Fix', 'susan'
|
|
|
|
|
thank you
but i dont understand where i must do it and how ?
sorry im a beginer
|
|
|
|
|
good evening
i have made a online reservation airline tickets website ,my question is if many users reserves online at the same how can the database will respond to those users ,i knew that there is (isolation level )enum that solves this problem but i don't know how to use it in the code
thanks in advance
|
|
|
|
|
Sounds like you need to use a transaction
BEGIN TRANSACTION
UPDATE tblOpenSeats (mark the seat as reserved)
INSERT INTO reservations...
COMMIT
|
|
|
|