Search Results

Search found 1168 results on 47 pages for 'datatable'.

Page 12/47 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • SQL Server Collation / ADO.NET DataTable.Locale with different languages

    - by Turro
    Hi all, we have WinForms app which stores data in SQL Server (2000, we are working on porting it in 2008) through ADO.NET (1.1, working on porting to 4.0). Everything works fine if I read data previsouly written in Western-European locale (E.g.: "test", "test ù"), but now we have to be able to mix Western and non-Western alphabets as well (E.g.: "test - ???" - these are just random arabic chars). On the SQL Server side, database has been set with the Latin1_General collation, the field is a nvarchar(80). If I run a SQL SELECT statement (E.g.: "SELECT * FROM MyTable WHERE field = 'test - ???'", don't mind about the "*" or the actual names) from Query Analyzer, I get no results; the same happens if I pass the Sql statement to an ADO.NET DataAdapter to fill a DataTable. My guess is that it has something to do with collation, but I don't know how to correct this: do I have to change to collation (SQL Server) to a different one? Or do I have to set the locale on the DataAdaoter/DataTable (ADO.NET)? Thanks in advance to anyone who will help

    Read the article

  • Editable, growable DataGrid that retains values on postback and updates underlying DataTable

    - by jlstrecker
    I'm trying to create an ASP.NET/C# page that allows the user to edit a table of data, add rows to it, and save the data back to the database. For the table of data, I'm using a DataGrid whose cells contain TextBoxes or CheckBoxes. I have a button for adding rows (which works) and a button for saving the data. However, I'm quite stuck on two things: The TextBoxes and CheckBoxes should retain their values on postback. So if the user edits a TextBox and clicks the button to add more rows, the edits should be retained when the page reloads. However, the edits should not be saved to the database at this point. When the user clicks the save button, or anytime before, the DataTable underlying the DataGrid needs to be updated with the values of the TextBoxes and CheckBoxes so that the DataTable can be sent to the database. I have a method that does this, but I can't figure out when to call it. Any help getting this to work, or suggestions of alternative user interfaces that would behave similarly, would be appreciated.

    Read the article

  • can't edit my h:datatable

    - by Mike
    hi! i have this code: <h:form> <rich:dataTable value="#{my.lreqs}" var="req" id="reqs" width="630px" > <rich:column label="Value" styleClass="schColL" width="90px" style="text-align:center"> <f:facet name="header"> <h:outputText value="#{my.colValue}" /> </f:facet> <h:inputText value="#{req.value}" > </h:inputText> </rich:column> </rich:dataTable> <h:commandButton value="Save" action="#{my.saveChanges}" ></h:commandButton> </h:form> and this is my bean: private List<Detail> lreqs; public List<Detail> getLreqs() { return lreqs; } public void setLreqs(List<Detail> lreqs) { this.lreqs = lreqs; } public void saveChanges() { firstNewValue = lreqs.get(0).getValue(); } but when i click save - a new value in req.value field is not being saved! why is it?

    Read the article

  • AFTER INVOKE_APPLICATION(5) is being skipped in my h:datatable

    - by Mike
    hi! i have this code: <h:form> <rich:dataTable value="#{my.lreqs}" var="req" id="reqs" width="630px" > <rich:column label="Value" styleClass="schColL" width="90px" style="text-align:center"> <f:facet name="header"> <h:outputText value="#{my.colValue}" /> </f:facet> <h:inputText value="#{req.value}" > </h:inputText> </rich:column> </rich:dataTable> <h:commandButton value="Save" action="#{my.saveChanges}" ></h:commandButton> </h:form> and this is my bean: private List<Detail> lreqs; public List<Detail> getLreqs() { return lreqs; } public void setLreqs(List<Detail> lreqs) { this.lreqs = lreqs; } but when i click save - a new value in req.value field is not being saved! i added phaseTracker and realised that my AFTER INVOKE_APPLICATION(5). why is it?

    Read the article

  • SQL WHERE clause not returning rows when field has NULL value

    - by JohnB
    Ok, so I'm aware of this issue: When SET ANSI_NULLS is ON, all comparisons against a null value evaluate to UNKNOWN SQL And NULL Values in where clause SQL Server return Rows that are not equal < to a value and NULL However, I am trying to query a DataTable. I could add to my query: OR col_1 IS NULL OR col_2 IS NULL for every column, but my table has 47 columns, and I'm building dynamic SQL (string concatenation), and it just seems like a pain to do that. Is there another solution? I was to bring back all the rows that have NULL values in the WHERE comparison. UPDATE Example of query that gave me problems: string query = col_1 not in ('Dorothy', 'Blanche') and col_2 not in ('Zborna', 'Devereaux') grid.DataContext = dataTable.Select(query).CopyToDataTable(); (didn't retrieve rows if/when col_1 = null and/or col_2 = null)

    Read the article

  • SubSonic 2.x now supports TVP's - SqlDbType.Structure / DataTables for SQL Server 2008

    - by ElHaix
    For those interested, I have now modified the SubSonic 2.x code to recognize and support DataTable parameter types. You can read more about SQL Server 2008 features here: http://download.microsoft.com/download/4/9/0/4906f81b-eb1a-49c3-bb05-ff3bcbb5d5ae/SQL%20SERVER%202008-RDBMS/T-SQL%20Enhancements%20with%20SQL%20Server%202008%20-%20Praveen%20Srivatsav.pdf What this enhancement will now allow you to do is to create a partial StoredProcedures.cs class, with a method that overrides the stored procedure wrapper method. A bit about good form: My DAL has no direct table access, and my DB only has execute permissions for that user to my sprocs. As such, SubSonic only generates the AllStructs and StoredProcedures classes. The SPROC: ALTER PROCEDURE [dbo].[testInsertToTestTVP] @UserDetails TestTVP READONLY, @Result INT OUT AS BEGIN SET NOCOUNT ON; SET @Result = -1 --SET IDENTITY_INSERT [dbo].[tbl_TestTVP] ON INSERT INTO [dbo].[tbl_TestTVP] ( [GroupInsertID], [FirstName], [LastName] ) SELECT [GroupInsertID], [FirstName], [LastName] FROM @UserDetails IF @@ROWCOUNT > 0 BEGIN SET @Result = 1 SELECT @Result RETURN @Result END --SET IDENTITY_INSERT [dbo].[tbl_TestTVP] OFF END The TVP: CREATE TYPE [dbo].[TestTVP] AS TABLE( [GroupInsertID] [varchar](50) NOT NULL, [FirstName] [varchar](50) NOT NULL, [LastName] [varchar](50) NOT NULL ) GO The the auto gen tool runs, it creates the following erroneous method: /// <summary> /// Creates an object wrapper for the testInsertToTestTVP Procedure /// </summary> public static StoredProcedure TestInsertToTestTVP(string UserDetails, int? Result) { SubSonic.StoredProcedure sp = new SubSonic.StoredProcedure("testInsertToTestTVP", DataService.GetInstance("MyDAL"), "dbo"); sp.Command.AddParameter("@UserDetails", UserDetails, DbType.AnsiString, null, null); sp.Command.AddOutputParameter("@Result", DbType.Int32, 0, 10); return sp; } It sets UserDetails as type string. As it's good form to have two folders for a SubSonic DAL - Custom and Generated, I created a StoredProcedures.cs partial class in Custom that looks like this: /// <summary> /// Creates an object wrapper for the testInsertToTestTVP Procedure /// </summary> public static StoredProcedure TestInsertToTestTVP(DataTable dt, int? Result) { DataSet ds = new DataSet(); SubSonic.StoredProcedure sp = new SubSonic.StoredProcedure("testInsertToTestTVP", DataService.GetInstance("MyDAL"), "dbo"); // TODO: Modify the SubSonic code base in sp.Command.AddParameter to accept // a parameter type of System.Data.SqlDbType.Structured, as it currently only accepts // System.Data.DbType. //sp.Command.AddParameter("@UserDetails", dt, System.Data.SqlDbType.Structured null, null); sp.Command.AddParameter("@UserDetails", dt, SqlDbType.Structured); sp.Command.AddOutputParameter("@Result", DbType.Int32, 0, 10); return sp; } As you can see, the method signature now contains a DataTable, and with my modification to the SubSonic framework, this now works perfectly. I'm wondering if the SubSonic guys can modify the auto-gen to recognize a TVP in a sproc signature, as to avoid having to re-write the warpper? Does SubSonic 3.x support Structured data types? Also, I'm sure many will be interested in using this code, so where can I upload the new code? Thanks.

    Read the article

  • C# and NpgsqlDataAdapter returning a single string instead of a data table

    - by tme321
    I have a postgresql db and a C# application to access it. I'm having a strange error with values I return from a NpgsqlDataAdapter.Fill command into a DataSet. I've got this code: NpgsqlCommand n = new NpgsqlCommand(); n.Connection = connector; // a class member NpgsqlConnection DataSet ds = new DataSet(); DataTable dt = new DataTable(); // DBTablesRef are just constants declared for // the db table names and columns ArrayList cols = new ArrayList(); cols.Add(DBTablesRef.all); //all is just * ArrayList idCol = new ArrayList(); idCol.Add(DBTablesRef.revIssID); ArrayList idVal = new ArrayList(); idVal.Add(idNum); // a function parameter // Select builder and Where builder are just small // functions that return an sql statement based // on the parameters. n is passed to the where // builder because the builder uses named // parameters and sets them in the NpgsqlCommand // passed in String select = SelectBuilder(DBTablesRef.revTableName, cols) + WhereBuilder(n,idCol, idVal); n.CommandText = select; try { NpgsqlDataAdapter da = new NpgsqlDataAdapter(n); ds.Reset(); // filling DataSet with result from NpgsqlDataAdapter da.Fill(ds); // C# DataSet takes multiple tables, but only the first is used here dt = ds.Tables[0]; } catch (Exception e) { Console.WriteLine(e.ToString()); } So my problem is this: the above code works perfectly, just like I want it to. However, if instead of doing a select on all (*) if I try to name individual columns to return from the query I get the information I asked for, but rather than being split up into seperate entries in the data table I get a string in the first index of the data table that looked something like: "(0,5,false,Bob Smith,7)" And the data is correct, I would be expecting 0, then 5, then a boolean, then some text etc. But I would (obviously) prefer it to not be returned as just one big string. Anyone know why if I do a select on * I get a datatable as expected, but if I do a select on specific columns I get a data table with one entry that is the string of the values I'm asking for?

    Read the article

  • Problem with MultiColumn Primary Key

    - by Mike
    DataTable NetPurch = new DataTable(); DataColumn[] Acct_n_Prod = new DataColumn[2]; DataColumn Account; Account = new DataColumn(); Account.DataType = typeof(string); Account.ColumnName = "Acct"; DataColumn Product; Product = new DataColumn(); Product.DataType = typeof(string); Product.ColumnName = "Prod"; NetPurch.Columns.Add(Account); NetPurch.Columns.Add(Product); Acct_n_Prod[0] = Account; Acct_n_Prod[1] = Product; NetPurch.PrimaryKey = Acct_n_Prod; NetPurch.Columns.Add(MoreColumns); the code is based on the example here When it is compiled and runs i get an error saying: "Expecting 2 values for the key being indexed but received only one" if I make Acct_n_Prod = new DataColumn[1] and comment out the line adding product to the acct-n-prod array then it runs fine I'm fairly new to this so I'm not sure where the error is Thanks, -Mike

    Read the article

  • DataView.RowFilter an ISO8601

    - by Ryan
    I have a DataTable (instance named: TimeTable) whose DefaultView (instance named: TimeTableView) I am trying to use to filter based on a date. Column clock_in contains an ISO8601 formatted string. I would like to select all the rows in this DataTable/DefaultView between 2009-10-08T08:22:02Z and 2009-10-08T20:22:02Z. What would I have to filter on this criteria? I tried: TimeTableView = TimeTable.DefaultView; TimeTableView.RowFilter = "clock_in >= #2009-10-08T08:22:02Z# and #2009-10-08T20:22:02Z#"; This is not working for me. Am I operating on the wrong object or is my filter syntax wrong?

    Read the article

  • Populate DataGridViewComboBoxColumn runtime

    - by ghiboz
    Hi all! I have this problem: I have a datagridview that reads the data from a db and I wish, for an integer column use a combobox to choose some values... I modified the column using DataGridViewComboBoxColumn type and after, on the init of the form this: DataTable dt = new DataTable("dtControlType"); dt.Columns.Add("f_Id"); dt.Columns.Add("f_Desc"); dt.Rows.Add(0, "none"); dt.Rows.Add(1, "value 1"); dt.Rows.Add(2, "value 2"); dt.Rows.Add(3, "value 3"); pControlType.DataSource = dt; pControlType.DataPropertyName = "pControlType"; pControlType.DisplayMember = "f_Desc"; pControlType.ValueMember = "f_Id"; but when the program starts (after this code) this message appears:

    Read the article

  • Modify values on-the-fly during SqlAdapter.Fill( )

    - by Timothy
    What would the proper way be to modify values on the fly as they are loaded into a DataTable by SqlAdapter.Fill()? I have globalized my application's log messages. An integer indicating the event type and serialized data relevant to the event is stored in the database as show below. When I display the logged events through a DataGridView control to the user, I interpolate the data to a formatting string. event_type event_timestamp event_details ============================================ 3 2010-05-04 20:49:58 jsmith 1 2010-05-04 20:50:42 jsmith ... I am currently iterating through the DataTable's rows to format the messages. public class LogDataTable : DataTable { public LogDataTable() { Locale = CultureInfo.CurrentCulture; Columns.AddRange(new DataColumn[] { new DataColumn("event_type", typeof(Int32)), new DataColumn("event_timestamp", typeof(DateTime)), new DataColumn("event_details", typeof(String))}); } } ... using (SqlDataAdapter adapter = new SqlDataAdapter(...)) { adapter.SelectCommand.Parameters.AddRange(new Object[] { ... }); adapter.Fill(table); } foreach (DataRow row in table.Rows) { switch ((LogEventType)row["event_type"]) { case LogEventType.Create: row["event_details"] = String.Format(Resources.Strings.LogEventCreateMsg, row["event_details"]; break; case LogEventType.Create: row["event_details"] = String.Format(Resources.Strings.LogEventCreateMsg, row["event_details"]; break; ... The end result as displayed would resemble: Type Date and Time Details ==================================================================== [icon] 2010-05-04 20:49:58 Failed login attempt with username jsmith [icon] 2010-05-04 20:50:42 Successful login with username jsmith ... It seems wasteful to iterate the result set twice-- once as the table is filled by the adapter, and again to perform the replacements. I would really like to do the replacement on-the-fly in my LogDataTable class as it is being populated. I have tried overriding an OnRowChanging method in LogDataTable, which throws an InRowChangingEventException. protected override void OnRowChanging(DataRowChangeEventArgs e) { base.OnRowChanging(e); switch ((LogEventType)row["event_type"]) ... I have tried overriding an OnRowChanged method, which throws a StackOverflowException (I assume changing it re-triggers the method ad infinitum?). I have tried overriding an OnTableNewRow method, which does not throw an exception but appears not to be invoked (I assume only when a user adds a row in the view, which I've prevented). I'd greatly appreciate any assistance anyone can give me.

    Read the article

  • Fastest way of creating XML from parent-child table in c#?

    - by rudnev
    Assume we have some DataTable or IEnumerable with ChildID, ParentID and Title. We need to serialize it to XML like <Entity title=""> <Entity title=""></Entity> <Entity title=""></Entity> </Entity> As i found out, standard DataTable.GetXML() returns something different. I thought about initializing class tree like Entity e = new Entity(ID, Title, ParentEntityID) and then serializing it. Table is about 3000 elems. Is there faster way?

    Read the article

  • Load a CSV file into a DataGrid

    - by Calanus
    I'm having a go at moving one of our simpler apps to Silverlight (a bit of a learning exercise). I've quickly come unstuck as I can't figure out how to load (or bind maybe?) a csv file to a datagrid (i.e. so you can point the app at a local csv file and display it to the user). I do have boilerplate code to parse a csv file and return a datatable but I'm shocked to discover that Silverlight doesn't even support DataTable (wtf!). Any ideas at all how to do this? How do people bind data to a datagrid anyhow? I'm using Silverlight 3.0 included in VS2010.

    Read the article

  • JSF : able to do mass update but unable to update a single row in a datatable

    - by nash
    I have a simple data object: Car. I am showing the properties of Car objects in a JSF datatable. If i display the properties using inputText tags, i am able to get the modified values in the managed bean. However i just want a single row editable. So have placed a edit button in a separate column and inputText and outputText for every property of Car. the edit button just toggles the rendering of inputText and outputText. Plus i placed a update button in a separate column which is used to save the updated values. However on clicking the update button, i still get the old values instead of the modified values. Here is the complete code: public class Car { int id; String brand; String color; public Car(int id, String brand, String color) { this.id = id; this.brand = brand; this.color = color; } //getters and setters of id, brand, color } Here is the managed bean: import java.util.ArrayList; import java.util.List; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import javax.faces.component.UIData; @ManagedBean(name = "CarTree") @RequestScoped public class CarTree { int editableRowId; List<Car> carList; private UIData myTable; public CarTree() { carList = new ArrayList<Car>(); carList.add(new Car(1, "jaguar", "grey")); carList.add(new Car(2, "ferari", "red")); carList.add(new Car(3, "camri", "steel")); } public String update() { System.out.println("updating..."); //below statments print old values, was expecting modified values System.out.println("new car brand is:" + ((Car) myTable.getRowData()).brand); System.out.println("new car color is:" + ((Car) myTable.getRowData()).color); //how to get modified row values in this method?? return null; } public int getEditableRowId() { return editableRowId; } public void setEditableRowId(int editableRowId) { this.editableRowId = editableRowId; } public UIData getMyTable() { return myTable; } public void setMyTable(UIData myTable) { this.myTable = myTable; } public List<Car> getCars() { return carList; } public void setCars(List<Car> carList) { this.carList = carList; } } here is the JSF 2 page: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <h:form id="carForm" prependId="false"> <h:dataTable id="dt" binding="#{CarTree.myTable}" value="#{CarTree.cars}" var="car" > <h:column> <h:outputText value="#{car.id}" /> </h:column> <h:column> <h:outputText value="#{car.brand}" rendered="#{CarTree.editableRowId != car.id}"/> <h:inputText value="#{car.brand}" rendered="#{CarTree.editableRowId == car.id}"/> </h:column> <h:column> <h:outputText value="#{car.color}" rendered="#{CarTree.editableRowId != car.id}"/> <h:inputText value="#{car.color}" rendered="#{CarTree.editableRowId == car.id}"/> </h:column> <h:column> <h:commandButton value="edit"> <f:setPropertyActionListener target="#{CarTree.editableRowId}" value="#{car.id}" /> </h:commandButton> </h:column> <h:column> <h:commandButton value="update" action="#{CarTree.update}"/> </h:column> </h:dataTable> </h:form> </h:body> </html> However if i just keep the inputText tags and remove the rendered attributes, i get the modified values in the update method. How can i get the modified values for the single row edit?

    Read the article

  • JSF, datatable and onRowClick

    - by asrijaal
    Hi there, I want a commandlink to be executed when the row is clicked in my datatable. I've created a <h:commandLink> in one of my columns, where a parameter is passed through <f:setActionPropertyListener/> Is there a clean solution to fire this link by a rowClick? Sure I could workaround my missing knowledge with some jQuery but there should be a cleaner way?

    Read the article

  • Datatable binding to a form is not working

    - by saurabh
    Hi All i am having a form which are having 4 lables and these lables value are displayed in the 4 textboxs, i am using MVVM and binding these textboxs with the Datatble which is coming through the typed dataset not the problem here is when i add a new row in the datatable with default values of columns and update ui by calling onpropertychanged event from my viewmodel , these values are not getting reflected on the form. Before adding a new row in the table , i am removing all previous rows and then add. TIA. Saurabh

    Read the article

  • DataTable Filter mystery

    - by user283897
    Hi, could you please help me find the reason of the mystery I've found? In the below code, I create a DataTable and filter it. When I use filter1, everything works as expected. When I use filter2, everything works as expected only if the SubsectionAmount variable is less than 10. As soon as I set SubsectionAmount=10, the dr2 array returns Nothing. I can't find what is wrong. Here is the code: Imports System.Data Partial Class FilterTest Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Call FilterTable() End Sub Sub FilterTable() Dim dtSubsections As New DataTable Dim SectionID As Integer, SubsectionID As Integer Dim SubsectionAmount As Integer Dim filter1 As String, filter2 As String Dim rowID As Integer Dim dr1() As DataRow, dr2() As DataRow With dtSubsections .Columns.Add("Section") .Columns.Add("Subsection") .Columns.Add("FieldString") SectionID = 1 SubsectionAmount = 10 '9 For SubsectionID = 1 To SubsectionAmount .Rows.Add(SectionID, SubsectionID, "abcd" & CStr(SubsectionID)) Next SubsectionID For rowID = 0 To .Rows.Count - 1 Response.Write(.Rows(rowID).Item(0).ToString & " " _ & .Rows(rowID).Item(1).ToString & " " _ & .Rows(rowID).Item(2).ToString & "<BR>") Next SubsectionID = 1 filter1 = "Section=" & SectionID & " AND " & "Subsection=" & SubsectionID filter2 = "Section=" & SectionID & " AND " & "Subsection=" & SubsectionID + 1 dr1 = .Select(filter1) dr2 = .Select(filter2) Response.Write(dr1.Length & "<BR>") Response.Write(dr2.Length & "<BR>") If dr1.Length > 0 Then Response.Write(dr1(0).Item("FieldString").ToString & "<BR>") End If If dr2.Length > 0 Then Response.Write(dr2(0).Item("FieldString").ToString & "<BR>") End If End With End Sub End Class

    Read the article

  • LINQ query on a DataTable

    - by Calanus
    I'm trying to perform a LINQ query on a DataTable object and bizarrely I am finding that performing such queries on DataTables is not straightforward. For example: var results = from myRow in myDataTable where results.Field("RowNo") == 1 select results; This is not allowed. Any ideas how to get something like this working? I'm amazed that LINQ queries are not allowed on DataTables!

    Read the article

  • Silverlight - DataTable

    - by Villager
    Hello, I have a need to basically create a matrix of values in my Silverlight 3 application. Is there anything equivalent to a DataTable that I could store a matrix of values within? Thank you,

    Read the article

  • How to get datarow array refering to datatable 's field value with linq

    - by Michael
    I want to use linq to get datarow array from a datatable which its string type ColumnA is not null or depending on its length 0 , so I can get the row index with Indexof() method to deal with something else. ColumnA ColumnB ColumnC A0 B0 C0 Null B1 C1 A2 B2 C2 Null B3 C3 My Linq Statment: DataRow[] rows = myDataTable.Select("ColumnA is not null").Where(row=>row.Field<string>("ColumnA").Length>0); somebody who can help?

    Read the article

  • how to bind ComboBox with DataTable

    - by niko
    Hi, I have the DataTable with following columns: id, Name, Description, ParentId and would like to create a WPF control (.NET 4.0 framework) which implements a combobox which displays the names which are bound to values of id. So when the user selects a name displayed in the combobox the behind logic has to retrieve its id value. I would be very thankful if anyone could show the way of doing the described above.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >