Hi everyone.I am trying to write 2 INSERT INTO statements into a Button click event. Both statements go to the same database but differnet tables. The first statement works fine but the 2nd causes an error with the Try, Catch, Finally statement. When I remove the ExecuteNonQuery from the 2nd statement, the 2nd INSERT INTO statement fails to work. Any help would be brilliant. Thanks! Private Sub btnInsertChange_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Handles btnInsertChange.Command 'Insert Guide changes into ChangesReport table in sql server Me.SqlCommandThemeTest.Connection = Me.SqlConnection1 Dim Name As String Dim values As String Dim sSQL As String Name = "Theme, Guide, GuidePage, PageType, ChangeCategory, ChangeFrom, ChangeFromText, ChangeTo, ChangeToText ContentManager" values = "lstTheme, lstGuideName, lstGuidePage, lstPageType, lstChangeCategory, lstChangeFrom, txtChangeFrom, lstChangeTo, txtChangeTo, Label1" SqlCommandThemeTest.CommandText = "INSERT INTO dbo.ChangesReport (Theme, Guide, GuidePage, PageType, ChangeCategory, ChangeFrom, ChangeFromText, ChangeTo, ChangeToText, ContentManager) VALUES (@themeValue, @guideValue, @guidepageValue, @pagetypeValue, @changecategoryValue, @changefromValue, @changefromtextValue, @changetoValue, @changetotextValue, @contentmanagerValue)" SqlCommandThemeTest.Parameters.Add("@themeValue", lstTheme.SelectedItem.Text) SqlCommandThemeTest.Parameters.Add("@guideValue", lstGuideName.SelectedItem.Text) SqlCommandThemeTest.Parameters.Add("@guidepageValue", lstGuidePage.SelectedItem.Text) SqlCommandThemeTest.Parameters.Add("@pagetypeValue", lstPageType.SelectedItem.Text) SqlCommandThemeTest.Parameters.Add("@changecategoryValue", lstChangeCategory.SelectedItem.Text) SqlCommandThemeTest.Parameters.Add("@changefromValue", lstChangeFrom.SelectedItem.Text) SqlCommandThemeTest.Parameters.Add("@changefromtextValue", txtChangeFrom.Text) SqlCommandThemeTest.Parameters.Add("@changetoValue", lstChangeTo.SelectedItem.Text) SqlCommandThemeTest.Parameters.Add("@changetotextValue", txtChangeTo.Text) SqlCommandThemeTest.Parameters.Add("@contentmanagerValue", Label1.Text) Try Me.SqlConnection1.Open() Me.SqlCommandThemeTest.ExecuteNonQuery() Catch ex As Exception Response.Write(ex.ToString) Finally Me.SqlConnection1.Close() End Try 'Insert textbox to ChangeLogFrom ddl Me.CmdDDLFromUpdate.Connection = Me.SqlConnection1 Name = "ChangeFromText" values = "txtChangeFrom" sSQL = "INSERT INTO dbo.Change Log From (ChangeLogFrom) VALUES (@changelogfromValue)" Me.CmdDDLFromUpdate.Parameters.Add("@changelogfromValue", txtChangeFrom.Text) Try Me.SqlConnection1.Open() Me.CmdDDLFromUpdate.ExecuteNonQuery() Catch ex As Exception Response.Write(ex.ToString) Finally Me.SqlConnection1.Close() End Try
How can i confirm that the data entered within the standard controls and after the click event for the particular sql query the data is been stored in the database tables (depending insert,update,delete).I want to display the different messages on the click event and that after the changes made into the tables.How can i do it ?? I m using ASP.Net with C#,VB and the sql server to store data.I also want to know where are the database tables exactly get stored which are made in the Microsoft SQL Server Management Studio Express.I want to use as the existing item in .Net but could not find.. Thanxs...
I have written some code to insert a record into the table in BtnAdd click event and I also have a Grid view control to show the table records.
If I click the Add button ,the record gets inserted into the table and shown in the grid correspondingly.But if I refresh teh page,the same data gets inserted again since it fires the Btnclick Event.
Hello to everyone, I have this problem If I use this code when I try to update a record in my sql database It does not do anything. This is the code. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myconn As New SqlConnection("Data Source=.;Initial Catalog=SistemaIntegral; user id=sa") Dim mycmd As New SqlCommand("presup", myconn) mycmd.CommandType = CommandType.StoredProceduremycmd.parameters.Add(New SqlParameters("@txtClave", SqlDbtype.int,4)).Value=txtClave.textmycmd.parameters.Add(New SqlParameters("@txtForig", SqlDbtype.varchar,50)).Value=txtFOrig.textmycmd.parameters.Add(New SqlParameters("@txtFmod", SqlDbtype.varchar,50)).Value=txtFmod.textmycmd.parameters.Add(New SqlParameters("@txtFeje", SqlDbtype.varchar,50)).Value=txtFeje.textmycmd.parameters.Add(New SqlParameters("@txtPorig", SqlDbtype.varchar,50)).Value=txtPorig.textmycmd.parameters.Add(New SqlParameters("@txPmod", SqlDbtype.varchar,50)).Value=txtPmod.textmycmd.parameters.Add(New SqlParameters("@txtPeje", SqlDbtype.varchar,50)).Value=txtPeje.text mycmd.parameters.Add(New SqlParameters("@txtClave", SqlDbtype.int,4)).Value=txtClave.text myconn.Open() mycmd.ExecuteNonQuery() myconn.Close() mycmd.Dispose() myconn.Dispose() End Sub This is the code for the procedure called "presup" in SQL 2000 Server.CREATE PROCEDURE [presup](@txtClave [int],@txtForig [varchar](50),@txtFmod [varchar](50),@txtFeje [varchar](50),@txtPorig [varchar](50),@txtPmod [varchar](50),@txtPeje [varchar](50),@txtIdPresupuesto [int])as Update [Presupuesto]Set [IdClave]=@txtClave,[orig]=@txtForig,[moda]=@txtFmod,[ejer]=@txtFEje,[origr]=@txtPorig,[modar]=@txtPmod,[ejerr]=@txtPejeWhere ([IdPresupuesto]=@txtIdPresupuesto)GO When I click the Update button of my webform it does not do anything. Please Help me I am new to Visual Studio.Net 2003. (2 weeks ago I started using Visual Studio)
My SQL Server 2005 SP4 on Windows 2008 R2 is flooded with the below errors:-
Date 10/25/2011 10:55:46 AM Log SQL Server (Current - 10/25/2011 10:55:00 AM) Source spid Message Event Tracing for Windows failed to send an event. Send failures with the same error code may not be reported in the future. Error ID: 0, Event class ID: 54, Cause: (null).
Is there a way I can trace it how it is coming? When I check input buffer for these ids, it looks like it is tracing everything. All the general application DMLs are coming in these spids.
I have been testing with the WMI Event Watcher Task, so that I can identify a change to a file. The WQL is thus:
SELECT * FROM __InstanceModificationEvent within 30 WHERE targetinstance isa 'CIM_DataFile' AND targetinstance.name = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\AdventureWorks.bak'
This polls every 30 secs and in the SSIS Event (ActionAtEvent in the WMI Task is set to fire the SSIS Event) I have a simple script task that runs a message box).
My understanding is that the event polls every 30 s and if there is a change on the AdventureWorks.bak file then the event is triggered and the script task will run producing the message. However, when I run the package the message is occurring every 30s, meaning the event is continually firing even though there has been NO change to the AdventureWorks.bak file.
Am I correct in my understanding of how this should work and if so why is the event firing when it should not ?
Server 2003 SE SP1 5.2.3790 Sql Server 2000, SP 4, 8.00.2187 (latest hotfix rollup) We fixed one issue, but it brought up another. the fix we applied stopped the ServicesActive access failure, but now we have a failure on MSSEARCH. The users this is affecting do NOT have admin rights on the machine, they are SQL developers. We were having
Event Type: Failure Audit Event Source: Security Event Category: Object AccessEvent ID: 560 Date: 5/23/2007 Time: 6:27:15 AM User: domainuser Computer: MACHINENAME Description: Object Open: Object Server: SC Manager Object Type: SC_MANAGER OBJECT Object Name: ServicesActive Handle ID: - Operation ID: {0,1623975729} Process ID: 840 Image File Name: C:WINDOWSsystem32services.exe Primary User Name: MACHINE$ Primary Domain: Domain Primary Logon ID: (0x0,0x3E7) Client User Name: User Client Domain: Domain Client Logon ID: (0x0,0x6097C608) Accesses: READ_CONTROL Connect to service controller Enumerate services Query service database lock state
We recently upgraded to SQL 2005 from SQL 2000. We have most of our issues ironed out however about every 1 minute there is a message in the Application Event log and the SQL log that states:
EVENT ID 18456 Login Failed for the users DOMAIN/ACCOUNT [CLIENT: <local machine>]
This is a state 16 message which I thought meant that the account does not have access to the default database. The account is actually the account that the SQL services run under.
Any ideas? We can't seem to figure this one out. We actually upgraded to 2005 from 2000 and had an error appear after every reboot that prevented the SQL Agent from running(This application has failed to start because GAPI32.dll was not found. Re-installing the application may fix this problem.) We did a full uninstall of SQL and reinstalled fresh and restored the databases from .bak files and that is when the EVENT ID 18546 started occuring every minute.
We don't have any SQL heavy hitters here so please be detailed with any possible solutions. That you very much for any help you can provide!
Hey Guys, I'm not sure if anyone can help me with this but I am trying to achieve the following: I have a row (In this case it is information on a fix) and on a button click I am trying to get it to "archive" it. At the moment I have it so that it it takes the current information and adds it to the archive table adding an archive date. The thing that I am struggling with is incrementing the version number. So, I need it to (in these steps I think) - Look for existance of the other entires of that ID, look for the version number that is related to the newest date of those knowledgeIDs and then add 1 to it. If that knowledgeID doesnt exist then add it as one. My current code is below: Thanks in Advance =) C# Codeprotected void Page_Load(object sender, EventArgs e) {UserName = (string)Session["UserName"]; Label4.Text = UserName + " Is Current Logged In";UserType = (string)Session["UserType"];if ((Session["UserName"] != null) & (UserType == "Helpdesk")) {Response.Redirect("Accessrights.aspx"); }else if (Session["UserName"] == null) {Response.Redirect("Login.aspx"); } FixName = "default";Description = "default";File = "default"; ADate = myCalendar.TodaysDate.ToShortDateString(); AddDate = Convert.ToDateTime(ADate);myConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\inetpub\wwwroot\HOF\App_Data\HOF.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;"; }protected void Button1_Click(object sender, EventArgs e) {SqlConnection myConnection = new SqlConnection(myConnectionString); try { FixName = TextBox1.Text; SqlCommand myCommand = new SqlCommand("select * from Knowledge WHERE FixName like '%" + FixName + "%'", myConnection); myConnection.Open();SqlDataReader myReader = myCommand.ExecuteReader();if (myReader.HasRows) {while (myReader.Read()) { TextBox1.Text = myReader["FixName"].ToString();TextBox2.Text = myReader["Description"].ToString(); File = myReader["Location"].ToString();if (File != null) { TextBox3.Text = File; } else {TextBox3.Text = "There is no script avaliable"; }KnowledgeID = myReader["KnowledgeID"].ToString();Add = myReader["DateAdded"].ToString(); } myConnection.Close(); } else {TextBox1.Text = FixName + "Does not Exist. Please try again."; } }catch (Exception ex) { myConnection.Close(); } try Description = TextBox2.Text;File = Convert.ToString(FileUpload1.FileName);if (CheckBox1.Checked == true) {SAPPS = "True"; } else {SAPPS = "False"; } {SqlCommand mycommand2 = new SqlCommand("INSERT INTO Knowledge (FixName, Description, Location, DateAdded, DateArchived, Version, KnowledgeID) SET ('" + FixName + "','" + Description + "','" + File + "','" + Add + "','"+AddDate+"','" + SAPPS + "','"+I NEED A VALUE HERE+"','"+KnowledgeID+"')", myConnection);SqlDataAdapter myDataAdapter = new SqlDataAdapter(mycommand2); sa = mycommand.ExecuteNonQuery(); myConnection.Close(); }catch (Exception ex) { myConnection.Close(); } }
We installed an application named Streamserve. Now, if I go into Enterprise Manager I can expand the databases fine. But when I try to right-click properties Enterprise Manager goes bye bye. No error messages. I tried this on master and same thing. I currently have 2 different machines - a dev and a QA box and both are behaving badly.
i have a DTS Package a saved when i set up the package. it's in local packages in Enterprise Manager now. is there any way i can simply set up a shortcut on my desktop to execute that DTS, rather then having to nav though Enterprise Manager?
Hi everyone, Im using SSRS 2000 and I was wondering is there a way to create a click button??? I have 2 reports linked with hyperlinks but I wanted to make it look more presentable. So, instead of just clicking on the words, I want them to click the button.
I feel like it must be easy and I'm missing something. Maybe I'm going the wrong way about it too. Basically I've written an append query that needs parameters, but I have no idea how to actually execute it. I'm coming from building apps in MS Access where all of this is really easy. I'm really enjoying learning some things, and did my first MS SQL trigger event tonight, which worked great. I though using a trigger may be an option here, but I need to control the "when" of this append a little more carefully and can't rely on an automated event. I can manually execute the query and it works, but have a button I could press on a form, with the queries on that form would be ideal. I'm basically moving partial data from one table to another. Any help? Again, this seems like it "should" be easy, but I'm not finding info on it. Please talk slowly, as again, I'm coming from Access.
Table 1 = Product (one row per productID, also has second key, KEY2) Table 2 = Usage (many rows per KEY2)
I have a view that aggregates Usage GROUP BY Key2 - Usage_VIEW
I create a view over Product and Usave_view joining on KEY2 - Final_VIEW
When I query Product with a where Product = 'x' the time is under 1 second return. I then take the Key2 value returned and query my Usage_View the time is under 1 second to return.
BUT, if I query My Final_VIEW with where product = 'x' I can take a coffee break.
Question? Does the aggregate of Usage get performed before limiting to the matching rows in Product?
Can I use "Force Order" hint to make the first table limit the search on table 2? If so, please give syntax on FORCE ORDER. I can't seem to figure it out.
I am having a problem where I have a Summary Report for a Region that lists out data for each community in that region (sample below):
West Region Count
Community 1 N/A
Community 2 14
Community 3 41
Community 4 25
Community 5 38
Community 6 67
Community 7 40
Community 8 52
I have navigation setup such that when I click on a Community (like Community_1 above), the detailed community report is called. I am passing CommunityID as a parameter to the community report. The community report has a CommunityID (literally) parameter setup. This seems fine, but when I click on a community from the Region report (for example, Community_1 above), the community report does not automatically get rendered, it makes me select a community before it renders. I must have something setup incorrectly, but can't figure it out. Any ideas would be appreciated.
I want the community report to be rendered based on the selected community without having to select it again.
Hello friends Can anyone tell me the means by which I can populate a label or a datagrid by executing a selectcommand statement on the form of my webpage. And what is the best way to retrieve data from a SQL datasource, is it by using separate sqldatasources for each different parts of a page that requires different data from different tables in the same database or by using a tableadapter to retrieve the data for the best performance? Thanks for replying for my previous questions. It was helpful and great in my program implementation. Thank you
i am using a view grid to display data the viewgrid is tied to an sqldatasource control i want to give the user the ability of modifing data by colomn instead of by row how could i do ?
I am getting this error when clicking-through in Report Builder on a report using a report model as the data source - An item with the same key has already been added.
I searched for the error but came up empty in the SSRS space. Does anyone out there know when this is generated and where I need to look in my model/properties to see what I have set incorrectly?
A little background/detail - It's a simple report against two fields (type & #count) in one entity (customer) in a (guessing here) medium sized model (~16 transactional/fact entities, ~40 lookup entities, ~15 what I am calling domain entities). The entity has 5 DefaultDetailAttributes, one Identifying. The report has 2 fields type (a lookup role) and #customers in the data area (so I can click it to test the click through). Then I click the # Customers to look at the detail for those X customers and after a long while and no queries against the DB (I have profiler running) I get this error.
I have two reports. I need to provide a service that when the user click one hyperlink (or button), then the program can export these two reports to two files as PDF and let the user save it one by one. Is it possible?
I have a report which has 2 tables. The first table shows the current summary data as below.
ServerName Date ProjectStatus
Srv1 01/10 Green Srv2 01/10 Red Srv 3 01/10 Green
and the second shows the detailed history per server,
eg for Srv1
Table 2 ServerName Date ProjectStatus
Srv1 01/10 Green Srv1 01/09 Green Srv1 01/08 Red Srv1 01/07 Red Srv1 01/16 Red
I have a link on Srv1 column, on click of which i want to filter and show the data only for Srv1. If user clicks Srv2 data in table 2 should be refreshed with values only for Srv2.
How to do this ?
Note: I have done this using subreports but I dont want to use sub reports for when it comes to using them in web aspx page it has its own issues.
I want a single report to have this functionality.
I am not able to set the Report Parameter on click of link.
i am using 2 textbox to search name and instituition of some students. on button click need to display the result on gridview. but i dont get any result.. pl adviceSqlDataSource1.SelectCommand = "SELECT Sname, Address, Instituition, Role, Testgroup, Email FROM std_det WHERE (Sname LIKE '%'+@Param1+'%') AND (Instituition = 'RASET') AND (Role LIKE '%'+@Param2+'%') AND (Instituition = 'RASET')"; name.ControlID = "TextBox3"; name.DefaultValue = "%"; name.Name = "Param1"; name.PropertyName = "Text"; inst.ControlID = "TextBox4"; inst.DefaultValue = "%"; inst.Name = "Param2"; inst.PropertyName = "Text"; //SqlDataSource1.Select(DataSourceSelectArguments.Empty); SqlDataSource1.SelectParameters.Add(name); SqlDataSource1.SelectParameters.Add(inst); SqlDataSource1.DataBind(); //DataView dv = (DataView)this.SqlDataSource1.Select(DataSourceSelectArguments.Empty); GridView2.DataSourceID = "SqlDataSource1"; GridView2.DataBind();
I am new to ASP.NET so please excuse what may seem like a dumb question. I have a stored procedure that I need to run when the user clicks on our submit button. I am using Visual Studio 2005 and thought I could use the SqlDataSOurce Control. IS it possible to us the control or do I need to create a connection and call the stored procedure in the the button_click sub? Thanks in advance MF
i am using Asp.net , C# , sql server 2005. i made one rdl report and called it from server (win2003). it worked successfully . but when i give print for the same report(through reportviewer control print option). Client machine restart. Same thing happened on four machine that were in win2000.
We are having a weird problem. User printing a report have to press the print button twice to print a report. It is causing some problem and failing in QA too :-(.
I'm using vs2005. I can't print the reports by clicking the print icon only once, i have to do it twice.
After clicking OK in the print dialog box, I can see a pop up message that says it is printing but actually it is not printing, then if I repeat the process it will print. What could be the problem here? Please help. Thanks in advance. :)
I need help figuring out what setting I need to tweak to get the correct calculations for the default aggregate attributes for the related entities of the one I am drilling into. Right now it is calculating the total across all for every row and not slicing by sub-customer.
Example:
I have a customer with a one-to-many relationship to incidents. Both have a count aggregate that is part of the default aggregates for the entity. There are 58 rows in my table. If I run a report with CustomerName and #Incidents, I correctly get different sub totals for each customer, totalling to 58 for the grand total. However, if I run a summary report on customers and drill into the customers using click through, the #Incidents is displayed but it is 58 for all customers - every row.
If I go into the defaultDetailAttributes of the Customer and add the #Incidents to it and run the previous test, then the correct number of incidents are shown for the customer, then the incorrect number of incidents follow (from getting the aggregates from the children).
The query generated is huge and I am sure it has something to do with my OptionalMany relationships between the tables, but I can't understand why...
I have a form that contains data that some of which needs to be inserted into one table and the rest updated to another table. I want this to happen on a single button click. Is this possible?Here's what I have so far: String id = parm_tb_tktid.Text; String update = parm_tb_desc.Text; String status = parm_cb_status.Text; SqlCommand cmd = new SqlCommand("Insert into History (tkt_id, hist_desc) values(@parm_tb_tktid, @parm_tb_desc)", HelpdeskConnectionString); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@parm_tb_tktid", id); cmd.Parameters.AddWithValue("@parm_tb_desc", update); SqlCommand cmd1 = new SqlCommand("Update Ticket (tkt_status) values(@parm_cb_status) where tkt_id = @parm_tb_tktid)", HelpdeskConnectionString); cmd1.CommandType = CommandType.Text; cmd1.Parameters.AddWithValue("@parm_cb_status", status); HelpdeskConnectionString.Open(); cmd.ExecuteNonQuery(); cmd1.ExecuteNonQuery(); HelpdeskConnectionString.Close(); parm_tb_tktid.Text = String.Empty; parm_tb_desc.Text = String.Empty; parm_cb_status.Text = String.Empty;I know it isn't right, but I can't find any info on why it's wrong and how to code it properly.