Showing posts with label button. Show all posts
Showing posts with label button. Show all posts

Sunday, March 25, 2012

DataSet Update Problem

I know this is very very silly.
But I am stuck and don't know what to do.

I have a simple form which has 1 textbox and a 'Save' button.

I have created a Database connection and an Adapter with Dataset with
the help of Wizards.

I have binded by text box control to one of the database field.

When the form gets loaded it displays the field information correctly.
"Me.SqlDataAdapter1.Fill(DsBasicData1)"

However, when I press the save button it does not update the database
behind it.
I have given the following code to the click event of save button.
"Me.SqlDataAdapter1.Update(DsBasicData1)"

Strangely I don't know why the code does not work.patels (patels@.india.com) writes:
> I know this is very very silly.
> But I am stuck and don't know what to do.
> I have a simple form which has 1 textbox and a 'Save' button.
> I have created a Database connection and an Adapter with Dataset with
> the help of Wizards.
> I have binded by text box control to one of the database field.
> When the form gets loaded it displays the field information correctly.
> "Me.SqlDataAdapter1.Fill(DsBasicData1)"
> However, when I press the save button it does not update the database
> behind it.
> I have given the following code to the click event of save button.
> "Me.SqlDataAdapter1.Update(DsBasicData1)"
>
> Strangely I don't know why the code does not work.

And we don't know your database, or what's in that Update command.
Anyway, I think you should ask about this in a group devoted to
ADO .Net or Visual Studio .Net, as this is not really an
SQL Server issue per se.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Thursday, March 8, 2012

Data-driven subscriptions - SQLRS Ent vs Std

I want to use data-driven subscriptions but cannot create one - the "New
data-driven subscription" button does not appear in Report manager. I
believe this may be because I'm running SQLRS Standard - can someone confirm
this please?
If true, is there an easy way to upgrade to SQLRS Enterprise or do I have to
uninstall Std and do a fresh install of Enterprise? Is there a way to save
and restore all my subscriptions?
thanks
PeterThe data Driven Subscriptions are only part of the enterprise version. I
don't think you have to uninstall to put in the entprise license. It won't
affect your subscriptions.
Stuart
"PeterB" wrote:
> I want to use data-driven subscriptions but cannot create one - the "New
> data-driven subscription" button does not appear in Report manager. I
> believe this may be because I'm running SQLRS Standard - can someone confirm
> this please?
> If true, is there an easy way to upgrade to SQLRS Enterprise or do I have to
> uninstall Std and do a fresh install of Enterprise? Is there a way to save
> and restore all my subscriptions?
> thanks
> Peter|||From Microsoft Website
Evaluation, Developer, or Enterprise Edition of SQL Server 2005. Support for data-driven subscriptions is not available in Standard, Workgroup, or SQL Server Express Editions. For more information, see Features Supported by the Editions of SQL Server 2005.
EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com

Wednesday, March 7, 2012

data-driven subscription not available

I would like to setup a data-driven subscription for a report, but the New
Data-driven Subscription button is not available on the subscription page -
only the New Subscription button appears. I have checked that the report
uses a custom data source and stores the user name and password credentials
in the report server. The account that I am using to access Report Manager
is in the System Administrators role and the Content Manager role for the
report. What am I missing?
Thanks,
RobertDo you have Enterprise Edition? This feature is not available in Standard
Edition.
--
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"RMac" <@.news.postalias> wrote in message
news:EC568923-1967-44FE-8A17-4E2E67AC53D2@.microsoft.com...
>I would like to setup a data-driven subscription for a report, but the New
> Data-driven Subscription button is not available on the subscription
> page -
> only the New Subscription button appears. I have checked that the report
> uses a custom data source and stores the user name and password
> credentials
> in the report server. The account that I am using to access Report
> Manager
> is in the System Administrators role and the Content Manager role for the
> report. What am I missing?
> Thanks,
> Robert|||That is the problem then. I was not aware that Data-driven subscriptions
are not available in Standard Edition. Thanks Jasper.
"Jasper Smith" wrote:
> Do you have Enterprise Edition? This feature is not available in Standard
> Edition.
> --
> HTH
> Jasper Smith (SQL Server MVP)
> http://www.sqldbatips.com
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "RMac" <@.news.postalias> wrote in message
> news:EC568923-1967-44FE-8A17-4E2E67AC53D2@.microsoft.com...
> >I would like to setup a data-driven subscription for a report, but the New
> > Data-driven Subscription button is not available on the subscription
> > page -
> > only the New Subscription button appears. I have checked that the report
> > uses a custom data source and stores the user name and password
> > credentials
> > in the report server. The account that I am using to access Report
> > Manager
> > is in the System Administrators role and the Content Manager role for the
> > report. What am I missing?
> > Thanks,
> > Robert
>
>

Sunday, February 26, 2012

DataBinding to radio button

I have a windows form containing some text boxes and radio buttons bount to an SQL Server database, with code like the following:

this.tbBorrowerLastName.DataBindings.Add (new Binding("Text", dsData.Tables["Results"],"BorrowerLastName"();

this.rbMale.DataBindings.Add(new Binding("Checked", dsData.Tables["Results"],"Male"))

If I add a new row and try to move there using the code below, nothing happens (neither movement to a new position nor error message), unless I remove the radio button bindings. (The same thing occurs if I attempt to move to any record that has a null value in the database field for a radio button).

myLastRow = dsData.Tables["Results"].NewRow();

dsData.Tables["Results"].Rows.Add(myLastRow);

I attempt to move by changing the value of the position property of the BindingContext object.

How can I retain the radio button bindings and still be able to add and move to a new row?

Any help would be appreciated.

I was able to figure my own solution.

The problem was a null value for the checked property of the radio buttons. I tried adding a default value to Visual Studio and to the database, but neither of those solved the problem.

Inbetween the two lines of code in my earlier post (beginning myLastRow and dsData.Tables respectively), I added:

myLastRow["Male"]=true;

myLastRow["Female"]=false;

Problem solved.

Friday, February 17, 2012

Database versipn (C.0.8.40) does not match

When I click the "Upgrade" button while trying to configure reporting
services I get a couple of errors here are the two errors:
"Verify Database Version" First Yellow "!" Says :
The database version (C.0.8.40) does not match your reporting services
installation. You must upgrade your reporting services database.
"Create Upgrade Script for Database Version" Second Yellow "!" say:
Couldn't generate the upgrade script. There is no upgrade script available
for this version.
Has anyone seen these errors before. How to I get around these. Right now
my "Database Setup" in has a red "X" on the "Reporting Services Configuration
Manager" window.I have the same exact problem. Any fixes yet?
--
---
Yes, I searched first :)
"Greg Larsen" wrote:
> When I click the "Upgrade" button while trying to configure reporting
> services I get a couple of errors here are the two errors:
> "Verify Database Version" First Yellow "!" Says :
> The database version (C.0.8.40) does not match your reporting services
> installation. You must upgrade your reporting services database.
> "Create Upgrade Script for Database Version" Second Yellow "!" say:
> Couldn't generate the upgrade script. There is no upgrade script available
> for this version.
> Has anyone seen these errors before. How to I get around these. Right now
> my "Database Setup" in has a red "X" on the "Reporting Services Configuration
> Manager" window.
>|||Do you have a resolution to this issue? I ahve the exact same problem.
"Greg Larsen" wrote:
> When I click the "Upgrade" button while trying to configure reporting
> services I get a couple of errors here are the two errors:
> "Verify Database Version" First Yellow "!" Says :
> The database version (C.0.8.40) does not match your reporting services
> installation. You must upgrade your reporting services database.
> "Create Upgrade Script for Database Version" Second Yellow "!" say:
> Couldn't generate the upgrade script. There is no upgrade script available
> for this version.
> Has anyone seen these errors before. How to I get around these. Right now
> my "Database Setup" in has a red "X" on the "Reporting Services Configuration
> Manager" window.
>|||I had the same problem.
It was caused by that I had installed reporting services after I had run
SP1 on SQL Server 2005.
Solved it by runing SQL Server 2005 SP1 again.
Hope this helps!
"Rich" wrote:
> Do you have a resolution to this issue? I ahve the exact same problem.
> "Greg Larsen" wrote:
> > When I click the "Upgrade" button while trying to configure reporting
> > services I get a couple of errors here are the two errors:
> >
> > "Verify Database Version" First Yellow "!" Says :
> > The database version (C.0.8.40) does not match your reporting services
> > installation. You must upgrade your reporting services database.
> >
> > "Create Upgrade Script for Database Version" Second Yellow "!" say:
> > Couldn't generate the upgrade script. There is no upgrade script available
> > for this version.
> >
> > Has anyone seen these errors before. How to I get around these. Right now
> > my "Database Setup" in has a red "X" on the "Reporting Services Configuration
> > Manager" window.
> >

Tuesday, February 14, 2012

Database update and insert problem

Hi,

I have 3 short(ish) questions, If someone could help I'd be very grateful..

This is the situation - I have a formview which contains a button, which on clicking should insert a row into one table, and update a column value of another. I will provide the code at the end.

1. On clicking, I get the error:

System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'.

it doesnt say where, but the stack trace is:

[SqlException (0x80131904): Incorrect syntax near the keyword 'WHERE'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +180
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2411
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +147
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1089
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +413
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +115
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +395
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +643
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.FormView.HandleUpdate(String commandArg, Boolean causesValidation) +1151
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +429
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +86
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4886

2. When updating, at the moment it will update with a new quantity provided in the text box, but id like the quantity in the textbox subtracted from the current column value - how would this be done?

3. For inserting, i was wondering if i need a command in the button_click to activate the insert command, similar to the one i have one for the update. I have tried but i cant seem to get the syntax right...

Code:

private bool ExecuteUpdate(int quantity)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\ASPNETDB.MDF;Integrated Security=True;User Instance=True";

con.Open();

SqlCommand command = new SqlCommand();
command.Connection = con;
TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1");
Label labname = (Label)FormView1.FindControl("Label3");
Label labid = (Label)FormView1.FindControl("Label13");

command.CommandText = "UPDATE Items SET Quantityavailable = @.qty WHERE productID=@.productID";
command.Parameters.Add("@.qty", TextBox1.Text);
command.Parameters.Add("@.productID", labid.Text);
command.ExecuteNonQuery();

con.Close();
return true;
}

private bool ExecuteInsert(String quantity)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\ASPNETDB.MDF;Integrated Security=True;User Instance=True";

con.Open();

SqlCommand command = new SqlCommand();
command.Connection = con;
TextBox TextBox1 = (TextBox)FormView1.FindControl("TextBox1");
Label labname = (Label)FormView1.FindControl("Label3");
Label labid = (Label)FormView1.FindControl("Label13");

command.CommandText = "INSERT INTO Transactions (Usersname)VALUES (@.User)"+
"INSERT INTO Transactions (Itemid)VALUES (@.productID)"+
"INSERT INTO Transactions (itemname)VALUES (@.Itemsname)"+
"INSERT INTO Transactions (Date)VALUES (+DateTime.Now.ToString() +)"+
"INSERT INTO Transactions (Qty)VALUES (@.qty)"+
command.Parameters.Add("@.User", System.Web.HttpContext.Current.User.Identity.Name);
command.Parameters.Add("@.Itemsname", labname.Text);
command.Parameters.Add("@.productID", labid.Text);
command.Parameters.Add("@.qty", TextBox1.Text);
command.ExecuteNonQuery();

con.Close();
return true;
}

protected void Button2_Click(object sender, EventArgs e)
{
TextBox TextBox1 = FormView1.FindControl("TextBox1") as TextBox;
ExecuteUpdate(Int32.Parse(TextBox1.Text) );

}

Huge thanks for anyone who can help shed some light!!

Thanks again,

Jon

1. Debug your application and see the query which is being executed by the SqlDataSource's update event. There might be a space missing in the query. The error is self explanatory - there is syntax error. Try to run the query in the query analyzer.

2.

' After successful updationdim qty asInteger =Integer(QuantityTB.TextBox)dim available asInteger =Integer(AvailableTB.TextBox)' Update the available text boxAvailableTB.TextBox = available - qty
3.
if e.CommandName ="insert" then SqlDataSource1.Insert()end if
|||

Hi, thanks for your response!

1. I had tried debugging but it didn't detect any errors or warnings.. is this what you mean or am i missing the point?

2. I meant to update the column in the database table - it currently updates with just the number that is written in the textbox, but id like it to take away the number written in the textbox from the number that is in their already - do you mean use this code to create a textbox, then update the table with this new value?

3. Is that VB? Do you have it in C# if it is? Or if it isn't, where shall I put it? it doesn't like the syntax in button2_click...

Thanks alot for your help!!!

Cheers,

Jon

|||

1. When I meant debug, put a breakpoint after the query has been formed and now check the value of the query. Copy this to the query analyzer and see if it runs fine. If it does then your query is fine, problem lies somewhere else. If it does not, watch out the error thrown by query analyzer. In your original post, you had written that you were getting error message. Did that error disappear?

2. When you insert the ordered quantity, I thought you would deduct the quantity from the stock. I would suggest, whenever you want to insert a ordered product, then it should be like one transaction.

a. Check if the ordered quantity is not bigger than the available stock.

b. Only add the record, if the above condition is true. If the transaction went through OK, rebind the grid, so that it will show new values.

c. Rebinding of the gridview is good practice, because there can be more than a single user attempting to fill out the order.

No, you do not need to create a new textbox. I was just showing how to update the UI.

3. It is in VB, but simple to convert to C#. It ideally would be in the command event handler of the Insert button.

void InsertCommandBtn_Command(Object sender, CommandEventArgs e) {if (e.CommandName =="insert") { SqlDataSource1.Insert(); }}
|||

Hi cheers for help.

Your code seems to work fine. Im getting a different error message now, and need help updating the table - Ill put it to the forum.

Thanks again!

Jon