|
|
I just SELECT it and use a FileStream to write it. Here's an example:
byte[] content = (byte[]) ds [ 1 ].Rows [ i ] [ "FileContent" ] ;
fs.Write ( content , 0 , content.Length ) ;
fs.Close() ;
ds is a DataSet, and fs is the FileStream.
|
|
|
|
|
that is not really streaming anything, so I'd recommend a simple File.WriteAllBytes() .
BTW: I'm a bit puzzled by the ds[1] part...
|
|
|
|
|
Luc Pattyn wrote: File.WriteAllBytes().
In the case I quoted, I had to check whether or not a file by the chosen name existed first. There's no point creating the file if it already exists.
So I use a FileInfo to check Exists and simply use its Open method to get a FileStream.
Luc Pattyn wrote: the ds[1] part
refers to the oneth DataTable in the DataSet -- the set of files I want to create.
|
|
|
|
|
|
I am using a SQL statement to fill the contents of a subform's RecordSource:
Me.sub_NestedSchedule.Form.RecordSource = strMySqlStatement
How can I create a "virtual table" that has the empty string for all 6 of its fields and force that into my subform's RecordSource?
I want to initialize the subform during OnLoad and have the empty string.
Thanks,
JJM
|
|
|
|
|
Not sure how you are using the sql string but if you query the table with a nonsense where clause you will get back and empty data table.
Select * from MyTable where IDField = 0
Select * from MyTable where 1=1
These will return an empty datatable
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Select * from MyTable where 1=1
I think the previous SQL statement will return all rows in table
I think this is what you want to say
Select * from MyTable where 1=2
In addition to those solutions we can use
Select top 0 * from MyTable
|
|
|
|
|
YES! That's the ticket...
To initialize my RecordSource with an empty table that has the EmptyString instead of "#Name?" appearing, here is what I did.
I used a table that had a text data field (Label) and has as default value the empty string. I know that this table (tbl_MyHandyTable) will always be present. So I did this:
strSQL_subform = "SELECT [Lable] AS field1, [Label] AS field2, "
strSQL_subform = strSQL_subform + "[Label] AS field-N, "
...
strSQL_subform = strSQL_subform + "FROM [tbl_MyHandyTable] "
strSQL_subform = strSQL_subform + "WHERE 1=2;"
'initialize the record source with the empty table of EmptyStrings
Me.RecordSource = strSQL_subform
Thanks all!
|
|
|
|
|
Thanks, i understood what you were getting at and arrived at my solution - following post.
|
|
|
|
|
The ExecuteReader() function of a command can receive a CommandBehavior parameter. Why not use CommandBehavior.SchemaOnly or CommandBehavior.KeyInfo ? E.g.
SqlCommand cmd = new SqlCommand("SELECT * FROM MyTable");
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly);
|
|
|
|
|
Hi guys.
I have a problem. I need to call a Stored Procedure inside a Stored Procedure and count the number of rows returned by the second SP. Something like this:
COUNT(EXEC My_SP 1,1,1,1).
That second SP returns a query with a x number or rows.
Thanks in advance guys.
|
|
|
|
|
Declare your second SP like
CREATE PROCEDURE My_SP
@Para1 AS INTEGER,
@Para2 AS INTEGER,
@Para3 AS INTEGER,
@RecordCount AS INTEGER OUTPUT
AS
SET @RecordCount = (SELECT COUNT(*) FROM MYTABLE)
GO
In your first SP
Call this like
DECLARE @RecordCount AS INTEGER
EXEC My_SP 1, 1, 1, RecordCount OUTPUT
Thats it
|
|
|
|
|
Thanks man. Thats exactly what i was looking for.
|
|
|
|
|
how is vulnerability explained in database? Am completely blank about vulnerability. I want to no what does vulnerability mean how and where do we use.I want to no the meaning in terms of database or any other concepts.
|
|
|
|
|
|
So buy a book on database security, check out some of the database centric sites (SQLServerCentral.com), do some reseach.
You have asked this question in a forum where we help developers not teach wannabes
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Actually i was not asking you people to teach me. i searched in net couldnt get any thing so thought u people may no any ref so that i learn.
Any way thank you for the information.
|
|
|
|
|
I have a comma delimited text file with array type columns (number of columns may vary) to import into SQL 2005 DB Table. Need help please!
I was hoping to attach a safe (no vb or macro) Excel workbook that does a good displaying background data (picture), CSV file format and final SQL 2005 DB Table format as well. I can e-mail if someone has the time to review and provide some useful advice on how to handle my "array" type problem.
Thanks...
Dean Pugh
|
|
|
|
|
Does the column count vary per CSV file or are the number of columns different per row.
1
Read the title row, create a table based on the titles
2
Read the entire file create a table with the max columns
This article [^]may help with the techniques
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Good ideas. I seem to have found an option that works pretty good. Using OPENROWSET my import works okay as long as the table has equal to or more columns than the csv file. In answer to your question, it is possible that different rows have different number of fields. So far in the examples I've played with Openrowset allows records to be added and any missing columns are taken off from the last columns. I can live with that since I can delete the rows later if needed. Now for the few records that were possibly causing the whole import to crash, I now get the whole import and can do a search and delete rows afterwards. Sorry for the delayed response. I've just got back to my computer. Many thanks for your ideas Mycroft, I would try them next.
Dean
|
|
|
|
|
Hy,
I have a problem in that I don't know what to choose.
We have somewhere DataLayer/BussinessLogic something like:
public class MainClass{
.
.
.
protected ObservableCollection<SecondaryClass> lst;
.
.
.
}
So the question is:
What is the best way to get some rows based on a array/list of IDs from the "main" table:
1) Getting all the MainClass rows/objects than generating a string from code(c#) using StringBuilder with all the IDs separated by commas and run a query/storedproc to get all objects from the realted
table(s) with a string/varchar paramter for the IN clause and fill the list of SecondaryClass objects from the MainClass or
2) Generate a temporary table with the IDs and use that in another
query/proc as the IN or EXISTS filter?
I've run some tests and for some reason or another from the speed point of view the first one is
the winner. But both are pretty fast. So speed alone is not that big of an issue.
Because of the Object Model we can not use a join. I mean we could but makes no sence.
Any suggestions will be apreciated.
Thanks
I bug
modified on Wednesday, July 14, 2010 1:47 PM
|
|
|
|
|
|
Nope.
Nice solution.
Thanks
I bug
|
|
|
|
|
You're welcome
|
|
|
|