Search Results

Search found 204 results on 9 pages for 'sqldatareader'.

Page 5/9 | < Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >

  • fill dropdown list by querystring

    - by KareemSaad
    I Had Drop down list and I want to fill it with data from database through stored procedure and it had it,s value when specific query string I had two query string. as private void LoadWithCategory() { if (Request.QueryString["Category_Id"] != null) { using (SqlConnection Con = Connection.GetConnection()) { SqlCommand Com = new SqlCommand("GetProducFamilyTP", Con); Com.CommandType = CommandType.StoredProcedure; Com.Parameters.Add(Parameter.NewInt("@Category_Id", Request.QueryString["Category_Id"])); SqlDataReader DR = Com.ExecuteReader(); if (DR.Read()) { DDLProductFamily.DataSource = DR; DDLProductFamily.DataTextField = DR["Name"].ToString(); DDLProductFamily.DataValueField = DR["ProductCategory_Id"].ToString(); DDLProductFamily.DataBind(); } DR.Close(); } } } ALTER Proc GetProducFamilyTP ( @Category_Id Int ) AS Select Distinct Categories.Category_Id ,ProductCategory.Name , ProductCategory.ProductCategory_Id From Category_ProductCategory Inner Join Categories On Category_ProductCategory.Category_Id=Categories.Category_Id Inner Join ProductCategory On Category_ProductCategory.ProductCategory_Id=ProductCategory.ProductCategory_Id Where Categories.Category_Id =@Category_Id but this error occurred DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name '4Door'.

    Read the article

  • Navigation Bar from database

    - by KareemSaad
    i had soulation .i want to make navigation bar with items i will select them as (category,Product,....) So i made stored to get them throught paramater will pass it,s value from query string as. ALTER Proc Navcategory ( @Category_Id Int ) As Select Distinct Categories.Category,Categories.Category_Id From Categories Where Category_Id=@Category_Id and i mentioned in cs as if (Request.QueryString["Category_Id"] != null) { Banar.ImageUrl = "Handlers/Banner.ashx?Category_Id=" + Request.QueryString["Category_Id"] + ""; using (SqlConnection conn = Connection.GetConnection()) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Navcategory"; cmd.Parameters.Add(Parameter.NewInt("@Category_Id", Request.QueryString["Category_Id"])); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { LblNavigaton.Visible = true; LblNavigaton.Text = dr["Category"].ToString(); } } } so the result will be ex. Fridge (Category when querstring(category_Id)) 4Door (Product when querystring (Product_Id)) But I want the result fridge4Door.......

    Read the article

  • Ado.net ExecuteReader giving duplication while binding with datagrid

    - by Irvin Dua
    I am using below mentioned Ado.net function and resultset bind with grid view, however I am getting the duplicate rows in the resultset. Please help me out. Thanks Private _products As New List(Of Product) Public Property Products As List(Of BusinessObjects.Product) Get Return _products End Get Set(ByVal value As List(Of BusinessObjects.Product)) _products = value End Set End Property Public Function GetProductDetails() As List(Of Product) Dim product As New BusinessObjects.Product Using connection As New SqlConnection connection.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString connection.Open() Using Command As New SqlCommand("select * from T_product", connection) Dim rdr As SqlDataReader rdr = Command.ExecuteReader While rdr.Read() product.ProductID = rdr("ProductID") product.ProductName = rdr("ProductName") Products.Add(product) End While GridView1.DataSource = Products GridView1.DataBind() End Using End Using Return Products End Function

    Read the article

  • Arraylist as repeater datasource (how to access from .aspx)

    - by Phil
    I have an arraylist: Dim downloadsarray As New ArrayList downloadsarray.Add(iconlink) downloadsarray.Add(imgpath) downloadsarray.Add(filesize) downloadsarray.Add(description) Which is the datasource of my repeater: DownloadsRepeater.DataSource = downloadsarray DownloadsRepeater.DataBind() Please can you tell me how I output the items in the array to the .aspx page. I usually use (when using sqldatareader as datasource): <%#Container.DataItem("1stcolumnnamestring")%> <%#Container.DataItem("2ndcolumnnamestring")%> But this does not work when using the arraylist as datasource. Thanks. ps... I know how to use <%#Container.DataItem% to dump everything but I need to get at the items in the array individually, not have them all ditched out to the page in one go. For example, item 1 contains a link, item 2 contains an image path, item 3 contains a description. I need to have them kick out in the correct order to build the link and icon correctly.

    Read the article

  • Fastest method for SQL Server inserts, updates, selects

    - by Ian
    I use SPs and this isn't an SP vs code-behind "Build your SQL command" question. I'm looking for a high-throughput method for a backend app that handles many small transactions. I use SQLDataReader for most of the returns since forward only works in most cases for me. I've seen it done many ways, and used most of them myself. Methods that define and accept the stored procedure parameters as parameters themselves and build using cmd.Parameters.Add (with or without specifying the DB value type and/or length) Assembling your SP params and their values into an array or hashtable, then passing to a more abstract method that parses the collection and then runs cmd.Parameters.Add Classes that represent tables, initializing the class upon need, setting the public properties that represent the table fields, and calling methods like Save, Load, etc I'm sure there are others I've seen but can't think of at the moment as well. I'm open to all suggestions.

    Read the article

  • Fastest method for SQL Server inserts, updates, selects from C# ASP.Net 2.0+

    - by Ian
    Hi All, long time listener, first time caller. I use SPs and this isn't an SP vs code-behind "Build your SQL command" question. I'm looking for a high-throughput method for a backend app that handles many small transactions. I use SQLDataReader for most of the returns since forward only works in most cases for me. I've seen it done many ways, and used most of them myself. Methods that define and accept the stored procedure parameters as parameters themselves and build using cmd.Parameters.Add (with or without specifying the DB value type and/or length) Assembling your SP params and their values into an array or hashtable, then passing to a more abstract method that parses the collection and then runs cmd.Parameters.Add Classes that represent tables, initializing the class upon need, setting the public properties that represent the table fields, and calling methods like Save, Load, etc I'm sure there are others I've seen but can't think of at the moment as well. I'm open to all suggestions.

    Read the article

  • Reusing datasource

    - by nubby
    I'm tying to use one database call and reuse that data for other controls - without having to do another call. Scenario: I call the books table which returns all the authors and titles. I create an author's list control called list1 to displays all the titles by Shakespeare and a list2 to display titles by Charles Dickens. Void Bindme() { string commandText = "Select * from books"; SqlCommand mycommand = new SqlCommand(commandText, datasource1); datasource1.Open(); SqlDataReader myReader1 = mycommand.ExecuteReader(); list1.DataSource = myReader1; list1.DataBind(); list2.DataSource = myReader1; list2.DataBind(); datasource1.Close(); } In my example only the first bind to the source, list1, gets data. Any ideas?

    Read the article

  • How can i return dataset perfectly from sql?

    - by Phsika
    i try to write a winform application: i dislike below codes: DataTable dt = new DataTable(); dt.Load(dr); ds = new DataSet(); ds.Tables.Add(dt); Above part of codes looks unsufficient.How can i best loading dataset? public class LoadDataset { public DataSet GetAllData(string sp) { return LoadSQL(sp); } private DataSet LoadSQL(string sp) { SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString()); SqlCommand cmd = new SqlCommand(sp, con); DataSet ds; try { con.Open(); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); ds = new DataSet(); ds.Tables.Add(dt); return ds; } finally { con.Dispose(); cmd.Dispose(); } } }

    Read the article

  • Raw SQL sent to SQL Server from .NET on stored procedure call

    - by Jeff Meatball Yang
    Is there a way to get the raw text that is sent to SQL Server, as seen in SQL Profiler, from the ADO.NET call? using(SqlConnection conn = new SqlConnection(connString)) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "GetSomeData"; cmd.Parameters.Add("@id").Value = someId; cmd.Parameters.Add("@someOtherParam").Value = "hello"; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); // this sends up the call: exec GetSomeData @id=24, @someOtherParam='hello' // how can I capture that and write it to debug? Debug.Write("exec GetSomeData @id=24, @someOtherParam='hello'"); }

    Read the article

  • "Cleanly" Deploying an ASP.NET Application with LINQ to SQL Server

    - by Bob Kaufman
    In my development environment, my SQL Server is PHILIP\SQLEXPRESS. In testing, it's ANNIE, and the live environment will have a third name yet to be determined. I would have assumed that updating the following statement in web.config would have been enough: <add name="MyConnectionString"providerName="System.Data.SqlClient" connectionString="Data Source=PHILIP\SQLEXPRESS;Initial Catalog=MyDtabase;Integrated Security=True" /> When using SqlConnection, SqlCommand, SqlDataReader and friends, that's all it took. Using LINQ, it doesn't seem to work that nicely. I see the servername repeated in my .dbml file as well as in Settings.settings. After changing it in all of those places, I get it to work. However if I'm doing a few deployments per day during testing, I want to avoid this regimen. My question is: is there a programmatic solution for LINQ to SQL that will allow me to specify the connection string once, preferably in web.config, and get everybody else to refer to it?

    Read the article

  • display image in image control

    - by KareemSaad
    I had Image control and I added code to display images But there is not any image displayed ASPX: <body> <form id="form1" runat="server"> <div dir='<%= sDirection %>'> <div id="ContentImage" runat="server"> <asp:Image ID="Image2" runat="server" /> </div> </div> </form> </body> C#: using (System.Data.SqlClient.SqlConnection con = Connection.GetConnection()) { string Sql = "Select Image From AboutUsData Where Id=@Id"; System.Data.SqlClient.SqlCommand com = new System.Data.SqlClient.SqlCommand(Sql, con); com.CommandType = System.Data.CommandType.Text; com.Parameters.Add(Parameter.NewInt("@Id", Request.QueryString["Id"].ToString())); System.Data.SqlClient.SqlDataReader dr = com.ExecuteReader(); if (dr.Read() && dr != null) { Image1.ImageUrl = dr["Image"].ToString(); } }

    Read the article

  • ADO.NET - DataRead Error

    - by user560706
    Hi, I am trying to display data from a column in my database onto my rich textbox, but I am getting mixed up between DataSet and DataReader - I know the majority of the code below is correct, I just get two lines containing errors, and I'm not sure why: // Create a connection string string ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\\Documents and Settings\\Harley\\Desktop\\Test.accdb"); string SQL = "SELECT * FROM Paragraph"; // create a connection object SqlConnection conn = new SqlConnection(ConnectionString); // Create a command object SqlCommand cmd = new SqlCommand(SQL, conn); conn.Open(); DataTable dt = new DataTable(); da.Fill(dt); //ERROR // Call ExecuteReader to return a DataReader SqlDataReader reader = cmd.ExecuteReader(); foreach(DataRow reader in dsRtn) //ERROR { richTextBox = richTextBox.Text + reader[0].ToString(); } //Release resources reader.Close(); conn.Close(); }

    Read the article

  • Can I use a stream to INSERT or UPDATE a row in SQL Server (C#)?

    - by Cheeso
    Suppose I have a VarBinary[MAX] column, can I insert or update into that column using a type derived from System.IO.Stream? How? I think that I can obtain a read-only stream from such a column using a SqlDataReader, calling GetSqlBytes() on the reader, getting the SqlBytes instance, and then referencing the Stream property on that. What I want is the converse - I want a stream for update or insert. Possible? (from c#... Without writing T-SQL ?)

    Read the article

  • multiple rows of a single table

    - by Amanjot Singh
    i am having a table with 3 col. viz id,profile_id,plugin_id.there can be more than 1 plugins associated with a single profile now how can i fetch from the database all the plugins associated with a profile_id which comes from the session variable defined in the login page when I try to apply the query for the same it returns the data with the plugin_id of the last record the query is as follows SqlCommand cmd1 = new SqlCommand("select plugin_id from profiles_plugins where profile_id=" + Convert.ToInt32(Session["cod"]), con); SqlDataReader dr1 = cmd1.ExecuteReader(); if (dr1.HasRows) { while (dr1.Read()) { Session["edp1"] = Convert.ToInt32(dr1[0]); } } dr1.Close(); cmd1.Dispose();

    Read the article

  • whatz wrong in this SELECt query of MSSQL... ?

    - by user522211
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim SQLData As New System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True") Dim cmdSelect As New System.Data.SqlClient.SqlCommand("SELECT * FROM Table1 WHERE Date =" & TextBox1.Text & "'", SQLData) SQLData.Open() Dim dtrReader As System.Data.SqlClient.SqlDataReader = cmdSelect.ExecuteReader() While dtrReader.Read() For j As Integer = 1 To 31 Dim s As String = "s" & j If dtrReader(s.ToString()).ToString() = "b" Then Dim img As ImageButton = DirectCast(Panel1.FindControl(s.ToString()), ImageButton) img.ImageUrl = "~/Images/booked.gif" img.Enabled = False End If Next End While dtrReader.Close() SQLData.Close() End Sub SHOWS AN ERROR : Unclosed quotation mark after the character string ''.

    Read the article

  • Returning multiple datasets from a stored proc in VB

    - by Ryan Stephens
    I have an encrypted SQL Server stored proc that I run with (or the vb .net equivalent code of): declare @p4 nvarchar(100) set @p4=NULL declare @p5 bigint set @p5=NULL exec AA_PAY_BACS_EXPORT_RETRIEVE_S @PS_UserId=N'ADMN', @PS_Department=N'', @PS_PayFrequency=2, @PS_ErrorDescription=@p4 output select @p4, @p5 this returns 2 datasets and the output parameters for the results, the datasets are made up of various table joins etc, one holds the header record and one the detail records. I need to get the 2 datasets into a structure in VB .net (e.g. linq, sqldatareader, typed datasets) so that I can code with them, I don't know what tables any of this comes from and there are alot of them Whooopeee!!! I came close using Linq to SQL and IMultipleResults but got frustrated when I had to recode it every time I made a change to the designer file. My feelings are that there must be a simple way to do this, any ideas?

    Read the article

  • Which Namespaces Must Be Used to Connect to SQL Server with ADO.NET?

    - by every_answer_gets_a_point
    i am using this example to connect c# to sql server. can you please tell me what i have to include in order to be able to use sqlconnection? it must be something like: using Sqlconnection; ??? string connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=""C:\SQL Server 2000 Sample Databases\NORTHWND.MDF"";Integrated Security=True;Connect Timeout=30;User Instance=True"; SqlConnection sqlCon = new SqlConnection(connectionString); sqlCon.Open(); string commandString = "SELECT * FROM Customers"; SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon); SqlDataReader dataReader = sqlCmd.ExecuteReader(); while (dataReader.Read()) { Console.WriteLine(String.Format("{0} {1}", dataReader["CompanyName"], dataReader["ContactName"])); } dataReader.Close(); sqlCon.Close();

    Read the article

  • C# SQL SELECT Statement

    - by Feren6
    I have the following code: SqlCommand cmd2 = new SqlCommand("SELECT ClaimId FROM tblPayment WHERE PaymentId = " + PaymentID.ToString(), mvarDBConn); SqlDataReader reader = cmd2.ExecuteReader(); reader.Read(); Int32 ClaimId = reader.GetInt32(0); reader.Close(); If I run the SELECT statement in SQL it returns the number fine, but when I use ExecuteReader all it returns is 0. I've tried multiple methods including ExecuteScalar, ExecuteNonQuery, reader.GetString then casting that to an int, etc. What am I missing? Thanks.

    Read the article

  • I want search a item frome database

    - by vishal
    I want search a item frome database bye date and id but if I want to search only by date or id tahn data are display but if I want to search by both date and id than not both are display but combine both and than display. my code: SqlConnection con = new SqlConnection("Data Source=NODE5-PC;Initial Catalog=hans;Persist Security Info=True;User ID=sa;Password=123"); cmd = new SqlCommand("SELECT UserId, Date, Report FROM Daily_Report WHERE (Date='" + txtdate.Text + "' or UserId='" + txtempid.Text + "') OR (UserId='" + txtempid.Text + "' and UserId='" + txtempid.Text + "')", con); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); GridView2.DataSource = rdr; GridView2.DataBind(); con.Close();

    Read the article

  • what does this string.format piece of code do?

    - by jbkkd
    I have this piece of code in c#: private static void _constructRow(SqlDataReader reader, system.IO.StreamWriter stwr, bool getColumnName) { for (int i = 0; i < reader.FieldCount; i++) stwr.Writeline(String.Format("<td>{0}</td"), getColumnName ? reader.GetName(i) : reader.GetValue(i).ToString())); } I'm trying to understand what the part that start with "getColumnName ?" and ends with ".ToString()" does. I understood that it is a system.object type, but I have no idea what it specifically does or how it works. I want that because of this: "reader" had multiple rows in it, and I want to writeline only specific rows. If anyone can help me on either of those, I'd be grateful.

    Read the article

  • Fastest method for SQL Server inserts, updates, selects

    - by Ian
    I use SPs and this isn't an SP vs code-behind "Build your SQL command" question. I'm looking for a high-throughput method for a backend app that handles many small transactions. I use SQLDataReader for most of the returns since forward only works in most cases for me. I've seen it done many ways, and used most of them myself. Methods that define and accept the stored procedure parameters as parameters themselves and build using cmd.Parameters.Add (with or without specifying the DB value type and/or length) Assembling your SP params and their values into an array or hashtable, then passing to a more abstract method that parses the collection and then runs cmd.Parameters.Add Classes that represent tables, initializing the class upon need, setting the public properties that represent the table fields, and calling methods like Save, Load, etc I'm sure there are others I've seen but can't think of at the moment as well. I'm open to all suggestions.

    Read the article

  • Use of unassigned local variable

    - by Bob
    ... ... ... try { string Tags_collect; SqlDataReader Data1 = cmd.ExecuteReader(); Data1.Read(); lbl_q_title.Text = Data1["subject"].ToString(); Data1.NextResult(); while (Data1.Read()) { Tags_collect = Data1.GetString(0); Tags_collect= Tags_collect+ Tags_collect; } lbl_tags.Text = Tags_collect; ..... .... .... not sure why i get this error what do i miss?

    Read the article

  • Correct syntax in stored procedure and method using MsSqlProvider.ExecProcedure? [migrated]

    - by Dudi
    I have problem with ASP.net and database prcedure My procedure in mssql base USE [dbase] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[top1000] @Published datetime output, @Title nvarchar(100) output, @Url nvarchar(1000) output, @Count INT output AS SET @Published = (SELECT TOP 1000 dbo.vst_download_files.dfl_date_public FROM dbo.vst_download_files ORDER BY dbo.vst_download_files.dfl_download_count DESC ) SET @Title = (SELECT TOP 1000 dbo.vst_download_files.dfl_name FROM dbo.vst_download_files ORDER BY dbo.vst_download_files.dfl_download_count DESC) SET @Url = (SELECT TOP 1000 dbo.vst_download_files.dfl_source_url FROM dbo.vst_download_files ORDER BY dbo.vst_download_files.dfl_download_count DESC) SET @Count = (SELECT TOP 1000 dbo.vst_download_files.dfl_download_count FROM dbo.vst_download_files ORDER BY dbo.vst_download_files.dfl_download_count DESC) And my proceduer in website project public static void Top1000() { List<DownloadFile> List = new List<DownloadFile>(); SqlDataReader dbReader; SqlParameter published = new SqlParameter("@Published", SqlDbType.DateTime2); published.Direction = ParameterDirection.Output; SqlParameter title = new SqlParameter("@Title", SqlDbType.NVarChar); title.Direction = ParameterDirection.Output; SqlParameter url = new SqlParameter("@Url", SqlDbType.NVarChar); url.Direction = ParameterDirection.Output; SqlParameter count = new SqlParameter("@Count", SqlDbType.Int); count.Direction = ParameterDirection.Output; SqlParameter[] parm = {published, title, count}; dbReader = MsSqlProvider.ExecProcedure("top1000", parm); try { while (dbReader.Read()) { DownloadFile df = new DownloadFile(); //df.AddDate = dbReader["dfl_date_public"]; df.Name = dbReader["dlf_name"].ToString(); df.SourceUrl = dbReader["dlf_source_url"].ToString(); df.DownloadCount = Convert.ToInt32(dbReader["dlf_download_count"]); List.Add(df); } XmlDocument top1000Xml = new XmlDocument(); XmlNode XMLNode = top1000Xml.CreateElement("products"); foreach (DownloadFile df in List) { XmlNode productNode = top1000Xml.CreateElement("product"); XmlNode publishedNode = top1000Xml.CreateElement("published"); publishedNode.InnerText = "data dodania"; XMLNode.AppendChild(publishedNode); XmlNode titleNode = top1000Xml.CreateElement("title"); titleNode.InnerText = df.Name; XMLNode.AppendChild(titleNode); } top1000Xml.AppendChild(XMLNode); top1000Xml.Save("\\pages\\test.xml"); } catch { } finally { dbReader.Close(); } } And if I made to MsSqlProvider.ExecProcedure("top1000", parm); I got String[1]: property Size has invalid size of 0. Where I shoudl look for solution? Procedure or method?

    Read the article

  • I am trying to create an windows application watcher? [migrated]

    - by Broken_Code
    I recently started coding in c #(in may this year) and well I find it best to learn by working with code. this application http://www.c-sharpcorner.com/UploadFile/satisharveti/ActiveApplicationWatcher01252007024921AM/ActiveApplicationWatcher.aspx. I am trying to recreate it however mine will be saving the information into an sql database(new at this as well). I am having some coding problems though as it does not do what I expect it to do. THis is the main code I am using. private void GetTotalTimer() { DateTime now = DateTime.Now; IntPtr hwnd = APIFunc.getforegroundWindow(); Int32 pid = APIFunc.GetWindowProcessID(hwnd); Process p = Process.GetProcessById(pid); appName = p.ProcessName; const int nChars = 256; int handle = 0; StringBuilder Buff = new StringBuilder(nChars); handle = GetForegroundWindow(); appltitle = APIFunc.ActiveApplTitle().Trim().Replace("\0", ""); //if (GetWindowText(handle, Buff, nChars) > 0) //{ // string strbuff = Buff.ToString(); // StrWindow = strbuff; #region insert statement try { if (Conn.State == ConnectionState.Closed) { Conn.Open(); } if (Conn.State == ConnectionState.Open) { SqlCommand com = new SqlCommand("Select top 1 [Window Title] From TimerLogs ORDER BY [Time of Event] DESC", Conn); SqlDataReader reader = com.ExecuteReader(); startTime = DateTime.Now; string time = now.ToString(); if (!reader.HasRows) { reader.Close(); cmd = new SqlCommand("insert into [TimerLogs] values(@time,@appName,@appltitle,@Elapsed_Time,@userName)", Conn); cmd.Parameters.AddWithValue("@time", time); cmd.Parameters.AddWithValue("@appName", appName); cmd.Parameters.AddWithValue("@appltitle", appltitle); cmd.Parameters.AddWithValue("@Elapsed_Time", blank.ToString()); cmd.Parameters.AddWithValue("@userName", userName); cmd.ExecuteNonQuery(); Conn.Close(); } else if(reader.HasRows) { reader.Read(); if (appltitle != reader.ToString()) { reader.Close(); endTime = DateTime.Now; appduration = endTime.Subtract(startTime); cmd = new SqlCommand("insert into [TimerLogs] values (@time,@appName,@appltitle,@Elapsed_Time,@userName)", Conn); cmd.Parameters.AddWithValue("@time", time); cmd.Parameters.AddWithValue("@appName", appName); cmd.Parameters.AddWithValue("@appltitle", appltitle); cmd.Parameters.AddWithValue("@Elapsed_Time", appduration.ToString()); cmd.Parameters.AddWithValue("@userName", userName); cmd.ExecuteNonQuery(); reader.Close(); Conn.Close(); } } } } catch (Exception) { } //} #endregion ActivityTimer.Start(); Processing = "Working"; } Unfortunately this is the result. it is not saving the data as I expect it to. What am i doing wrong I had thought that with the sql reader it would first check for a value and only save if they do not match however it is saving whether there is a match or not.

    Read the article

  • .Net Windows Service Throws EventType clr20r3 system.data.sqlclient.sql error

    - by William Edmondson
    I have a .Net/c# 2.0 windows service. The entry point is wrapped in a try catch block yet when I look at the server's application event log I seem a number of "EventType clr20r3" errors that are causing the service to die unexpectedly. The catch block has a "catch (Exception ex)". Each sql commands is of the type "CommandType.StoredProcedure" and are executed with SqlDataReader's. These sproc calls function correctly 99% of time and have all been thoroughly unit tested, profiled, and QA'd. I additionally wrapped these calls in try catch blocks just to be sure and am still experiencing these unhandled exceptions. This only in our production environment and cannot be duplicated in our dev or staging environments (even under heavy load). Why would my error handling not catch this particular error? Is there anyway to capture more detail as to the root cause of the problem? Here is an example of the event log: EventType clr20r3, P1 RDC.OrderProcessorService, P2 1.0.0.0, P3 4ae6a0d0, P4 system.data, P5 2.0.0.0, P6 4889deaf, P7 2490, P8 2c, P9 system.data.sqlclient.sql, P10 NIL. Additionally The Order Processor service terminated unexpectedly. It has done this 1 time(s). The following corrective action will be taken in 60000 milliseconds: Restart the service.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >