|
Surely this should have gone in the SQL / ADO.NET forum.
The SQL code is:
IF NOT EXISTS (SELECT * FROM dbo.sysobjects
WHERE id = OBJECT_ID(N'[dbo].[StoredProcedureName]')
AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
CREATE PROCEDURE ....
If you need to run this through a C# application just ExecuteNonQuery() on the SqlCommand like this:
SqlCommand cmd = new SqlCommand(sqlStatement, myConnection);
cmd.ExecuteNonQuery(); The above assumes that you already have a connection and it is open. The sqlStatement is a string that contains the completed contents of the SQL code above.
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
ok thnaks, i found another way to check the existance of the procedure thw procedure id:
proc dbo.Showhierarchy
(
@index int
)
As
Begin
declare @FolderIndex int, @FolderName varchar(30)
set @FolderName = (select Name from pdbfolder where FolderIndex= @Index)
print replicate ('_', @@nestlevel *4) + @FolderName
set @FolderIndex = (select min(FolderIndex) from pdbfolder where parentfolderindex = @index)
while @FolderIndex is not null
begin
exec Showhierarchy @FolderIndex
set @FolderIndex = (select min (FolderIndex) from pdbfolder
where parentfolderindex =@index and FolderIndex > @FolderIndex)
End
End
....
so in the create satement that u emailed i write the above proc as it, and i need to get the two values which is printed @FolderIndex, @FolderName
note that it is a recurcive proc
could u send me the correctes code
Thanks alot
Hamody
|
|
|
|
|
Really, you should be creating stored procedures in advance of running your application - unless it is some sort of installation applicataion.
You are not going to get any data out of this in a C# application because there are no SELECT statements that return data out of the stored procedure. The only time you get print statements back is if an error occurs and the contents of any print statements is captured in the SqlException.
Anyway, to run a stored procedure this is the code you need in C#
SqlCommand cmd = new SqlCommand("Showhierarchy", myConnection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@index", indexValue);
cmd.ExecuteReader();
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
ok, when u execute it in the query analyzer u get a printed results i need them to be used in my code.
i don't know i think about inserting them in a table but the insert statement didn't execute in the proc that i sent to u ...
i don't know how to get these printed data ...
have u any idea
Thanks alot
Hamody
|
|
|
|
|
Hi
I have two projects and one of the project have internal methods which should be used in another project.. so i used friend assemly concept and was able to solve the problem partially... my problem is one of my projects have other refernced assemblies (third party also..) for which i dont have the code, which are not signed with a strong name. Now inorder to complete the process i have to sign the referenced assemblies as well.. How do i do that? Plz Help...
Regards
Deepak.S
|
|
|
|
|
If the assemblies have been delay signed then you can do it using the Strong Name Tool.
e.g.
sn.exe -R thirdparty.dll myKey.snk
|
|
|
|
|
|
I'm having a VERY hard time finding material I can read to understand this stuff. So far I got a program to evaluate mathematical equations and a basic Lexer that splits a string simply into a stack like so...
Example string - FunctionName ( "Param1" );
Stack[5]SEMICOLON
Stack[4]CLOSE_PAREN
Stack[3]"Param1"
Stack[2]OPEN_PAREN
Stack[1]FunctionName
Basically it tells me when it hits a special character, and after that it tells me what's inside it. I'm having a really hard time explaining this, a bunch of source is available here:
www.insolence9.com/downloads/SBN.zip
Thanks
|
|
|
|
|
Hi all
i need a bit help in saving images into mysql database through my C#.net application.I had converted the image into byte array but when i insert it or update the feild by an insert or update statement exception is thrown.
can anyone guide me pls
Thanks
Monica
|
|
|
|
|
First step in getting help in this situation is telling us WHAT exception is throw and what your code/database schema looks like.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Can u give me any article regrading saving images in mysql database .
The problem is when i try to insert this byte array through insert command to mysql table where the feild is a long blob to save that image this exception comes Out of scope. I donot know whether the way i am doing is right or not. but it saves the image in SQL server database not in mysql
What I am doing is converting the image from a picturebox in to a byte array and then trying to insert in the blob feild. I donot know it is write or wrong.if there is any other method pls tell me
thanks
Monica
|
|
|
|
|
|
hi I did the same thing which u suggested in that link but i am getting this exception
An unhandled exception of type 'System.Data.DBConcurrencyException' occurred in system.data.dll
Additional information: Concurrency violation: the UpdateCommand affected 0 records.
my code is like this
The table is tblPatientMaster with feilds one PatPhoto thats is long Blob and one patientId that is a bigint.
public static void UpdatePatientPhoto( long PatID,ref byte[] content )
{
DataRow PatRow;
String ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings["DSN"];
String query= "Select* from tblpatientmaster where patientId = " +
PatID ;
OdbcConnection myConnection = new OdbcConnection(ConnectionString);
myConnection.Open();
OdbcDataAdapter myAdapter=new OdbcDataAdapter(query,myConnection);
DataSet ds= new DataSet("tblpatientmaster");
myAdapter.UpdateCommand = new OdbcCommand
("UPDATE tblpatientmaster SET " +
"PatPhoto = @iPHOTO " +
"WHERE patientId = @iPatNo", myConnection);
myAdapter.UpdateCommand.Parameters.Add("@iPHOTO", OdbcType.Binary,
content.Length, "patphoto");
myAdapter.UpdateCommand.Parameters.Add("@iPatNo", OdbcType.BigInt,
0, "patientId");
myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
myAdapter.FillSchema(ds, SchemaType.Source, "tblpatientmaster");
myAdapter.Fill(ds,"tblpatientmaster");
DataTable PatTable = ds.Tables["tblpatientmaster"];
PatRow = PatTable.Rows.Find(PatID);
PatRow.BeginEdit();
if (content.Length != 0)
{
PatRow["PatPhoto"] = content;
}
PatRow.EndEdit();
myAdapter.Update(ds,"tblpatientmaster");
}
Pls anybody can help me with this problem.
Thanks
Monica
|
|
|
|
|
Relatively new to Web Apps (I've used them before, but was just reusing code, not creating). What I need is to display data read from a database in the following manner:
Header Header2 Header3
Item1 Item4 Item7
Item2 Item5 Item8
Item3 Item6
So basically 8 items will be read from a database, and it will group the items based on the common Header property. When it has displayed 3 I want it to go to the next line. Any advice?
|
|
|
|
|
Yeah, a repeater will give you the control you need here. Although, if it were me, I'd make things easier by writing a stored procedure that created three columns so that the presentation tier didn't need to worry about anything but displaying it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I just realize it too out the spacing I put in, so it may be a bit deceiving. What I am getting is 8 items from a DB with a Category attribute. So say the result would be something like:
Name1 | Category1
Name2 | Category1
Name3 | Category2
Name4 | Category3
Name5 | Category3
And so on. Can I still do this with the repeater?
|
|
|
|
|
Oh, I see. You can still do it with a repeater, you could do it by creating three tables, one for each category, and then binding the dataset to the repeater and accessing the three tables in the data items for the three rows.
I still lean towards a stored procedure that returns one table with three rows, based on category. Then the presentation layer is easy, as it should be.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am writing a tool in .Net to display all group policy available in a domain and all application added to each policy. I am able to display all policy available in the domain but I cannot display the application assigned in the domain through the policy.
Can you please help me to display software names and other properties using vb.net or c#.net
Thanks,
Ram
|
|
|
|
|
How do you start another application from a C# program
|
|
|
|
|
Process.Start, from memory.
Yep[^], that's the one.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I want my Internet cafe solution has a firewall embedded within, how can I do that? is there any dll that I can use?
Thank you
|
|
|
|
|
it's doubtful there will be a DLL to do everything you need. If you want a real firewall you will need to do some driver level programming. I would suggest you start smaller.
-- Rocky Dean Pulley
|
|
|
|
|
A while ago I had asked for the proper approach to manage image mapping to dynamically created controls. The way that I have approached it thus far is to have some image files linked to the controls rather than adding them as a binary resource file into the control at loading time. Because I need to be able to overwrite the files on occasion, I still must keep the original image files like .jpeg or .gif files. What I would like to know is, is it possible to import those image files into the Image.FromStream() method into the Image file as a binary file programmatically rather than linking to the file? Load the image files into the controls in the onLoad event as binary files rather than linking to the external image files thereby removing that constraint on the application, but whenever new files are needed then the new image files could be loaded the same way.
Stated another way. First, what is the proper procedure for importing an image as a resource into an image-bearing control like a PictureBox control, and second, is it possible to use those image files as a resource programmatically? To be able to import the binary file into the control programmatically when the application starts would solve several problems including control invalidation and redrawing. Would really appreciate some insight.
|
|
|
|
|
I don't understand. If the jpg/gif files exist on disc, why do you need to use FromStream instead of FromFile ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Image.FromFile() locks down the image file handle so that it cannot be overwritten, whereas Image.FromStream() does not lock the file down. The question under these circumstances is, can I read the image file in binary form as a resource programmatically so that it stores the image file in binary format in the application as a resource as opposed to as a file handle? Also, could I read in other files in the same way dynamically (programmatically) so that it would simply overwrite the previously stored binary file as a resource?
|
|
|
|