Thursday, February 16, 2012
can a report read parameters from POST as opposed to GET?
allow the user to select various attributes, and I have to then create
the SQL clause on the fly, based off these selected attributes. I then
have to have the report in reporting services run off of that generated
SQL clause.
I have two ideas how I can do this, but I am looking for the most
efficient.
My first idea, and the one I assume I will have to go with is this.
When the user clicks the run button, the SQL clause will be built based
on their selections. That SQL clause will then get passed into a
stored proc which will act like a "middle man", this "middle man"
procedure will store the clause into a "holding" table. The Reporting
Services report will then have to run, use a procedure that reads from
this "holding" table and uses the SQL clause, executes it, and if
successful, deletes it from the holding table, ready for the next run
of the page.
The other approach I am thinking of, but am not sure will work is
basically passing the generated SQL query to the report as a POST
variable. I am not sure if this will work or not since I haven't tried
it before.
does anyone know if you can pass in POST variables as opposed to GET
variables when calling a report as a url?answered my own question by searching through the help (which I should
have done in the first place). So far it looks like I can POST the SQL
query that I want....but the help file mentions something about a 2000
char limit, for even POST...anyone have any experience with a similar
situation?
Tuesday, February 14, 2012
Can a DataTable update an SQL Table?
Can you use a DataTable to update an SQL Table and can it be done in a batch UPDATE as opposed to incrementing through every row using a stored procedure similar to UPDATE SQLTable SET Position = @.Position WHERE ID = @.ID?
Yes.. use the dataadapter and dataset
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson05.aspx
|||I think I found my misunderstanding with my approach. What I really should be asking is how to I access the Random001 in my DataSet in my Button1_Click event?
public DataTable GetRandLinks()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringA"].ConnectionString);
SqlCommand cmd = new SqlCommand("RandomizerSelect001", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
try
{
da.Fill(ds, "Random001");
return ds.Tables["Random001"];
}
catch
{ throw new ApplicationException("Data error"); }
}
protected void Button1_Click(object sender, EventArgs e)
{
NEED to know how to call the Random001 table so I can make changes in a loop, then write those changes up using da.Update? When I try I keep getting object not found?
}
Wait a bit - I think it finally may be seeing the breaking of dawn - - - -