Search Results

Search found 1402 results on 57 pages for 'dataset'.

Page 29/57 | < Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >

  • SVM Classification - minimum number of input sets for each class

    - by Amol Joshi
    Im trying to build an app to detect images which are advertisements from the webpages. Once I detect those Ill not be allowing those to be displayed on the client side. From the help that I got here in stackoverflow, I thought SVM is the best approach to my aim. So, I have coded SVM and an SMO myself. The dataset which I have got from UCI data repository has 3280 instances ( Link to Dataset- http://archive.ics.uci.edu/ml/datasets/Internet+Advertisements )where around 400 of them are from class representing Advertisement images and rest of them representing non-advertisement images. Right now Im taking the first 2800 input sets and training the SVM. But after looking at the accuracy rate I realised that most of those 2800 input sets are from non-advertisement image class. So Im getting very good accuracy for that class. So what can I do here? About how many input set shall I give to SVM to train and how many of them for each class? Thanks. Cheers. ( Basically made a new question because the context was different from my previous question. http://stackoverflow.com/questions/1991113/optimization-of-neural-network-input-data )

    Read the article

  • OleDBDataAdapter UNPIVOT Query not working with Microsoft.ACE.OLEDB.12.0 DataSource

    - by JayT
    I am reading in an excel file with an OleDBDataAdapter. I am using a select statement to UNPIVOT the data and insert into DataSet. However, the compiler is genereating this error: {"Syntax error in FROM clause."} But the SQL Statement is correct as I have used it in other DB's Here is the code: string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName + ";Extended Properties=\"Excel 12.0 Xml;HDR=" + HDR + ";IMEX=1\""; OleDbConnection conn = new OleDbConnection(strConn); conn.Open(); string SQL = "select Packhouse, Rm, Quantity , Product " + " FROM " + " ( " + " SELECT Date,Packhouse, Rm,[FG XL], [FG L] " + " FROM [" + xlSheet + "] " + " ) Main " + " UNPIVOT " + " ( " + " Quantity FOR Product in ([FG XL], [FG L]) " + " ) Sub " + " WHERE (Date = '2010/03/08') and Quantity <> '0' and Packhouse = 'A' and Rm = '1' "; OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.SelectCommand = new OleDbCommand(SQL, conn); ds[sequencecounter] = new DataSet(); adapter.Fill(ds[sequencecounter], xlSheet); If I copy and paste the excel data into a DB, then the select query works, but the data presented to me is in excel spreadsheets. If anyone could provide help on this it will be much appreciated. Regards, J

    Read the article

  • extracting RDL data using LINQ

    - by BobC
    I'm working with some SQL Report definition files (RDLs), using LINQ to extract component query statements for validation. I'm trying to extract the <DataSet> elements from under the <DataSets> element. I seem to be getting hung up with one of the elements under <DataSet><Fields><Field> which has a namespace qualifier <rd:TypeName> I've been using LINQ to XML for other parts of the files where there is no namespace qualifiers with no trouble, by specifying a default namespace. The RDL specifies two namespaces: xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"> When I try to get the <DataSets> element, however, I get the following error: System.Xml.XmlException - The ':' character, hexadecimal value 0x3A, cannot be included in a name. I know it has to do with the namespace qualifier (rd:) in one of the child elements, but I'm having difficulty getting a LINQ expression that works. Any help would be appreciated. Thanks!

    Read the article

  • Fitting Gaussian KDE in numpy/scipy in Python

    - by user248237
    I am fitting a Gaussian kernel density estimator to a variable that is the difference of two vectors, called "diff", as follows: gaussian_kde_covfact(diff, smoothing_param) -- where gaussian_kde_covfact is defined as: class gaussian_kde_covfact(stats.gaussian_kde): def __init__(self, dataset, covfact = 'scotts'): self.covfact = covfact scipy.stats.gaussian_kde.__init__(self, dataset) def _compute_covariance_(self): '''not used''' self.inv_cov = np.linalg.inv(self.covariance) self._norm_factor = sqrt(np.linalg.det(2*np.pi*self.covariance)) * self.n def covariance_factor(self): if self.covfact in ['sc', 'scotts']: return self.scotts_factor() if self.covfact in ['si', 'silverman']: return self.silverman_factor() elif self.covfact: return float(self.covfact) else: raise ValueError, \ 'covariance factor has to be scotts, silverman or a number' def reset_covfact(self, covfact): self.covfact = covfact self.covariance_factor() self._compute_covariance() This works, but there is an edge case where the diff is a vector of all 0s. In that case, I get the error: File "/srv/pkg/python/python-packages/python26/scipy/scipy-0.7.1/lib/python2.6/site-packages/scipy/stats/kde.py", line 334, in _compute_covariance self.inv_cov = linalg.inv(self.covariance) File "/srv/pkg/python/python-packages/python26/scipy/scipy-0.7.1/lib/python2.6/site-packages/scipy/linalg/basic.py", line 382, in inv if info>0: raise LinAlgError, "singular matrix" numpy.linalg.linalg.LinAlgError: singular matrix What's a way to get around this? In this case, I'd like it to return a density that's essentially peaked completely at a difference of 0, with no mass everywhere else. thanks.

    Read the article

  • How do I pass a lot of parameters to views in Django?

    - by Mark
    I'm very new to Django and I'm trying to build an application to present my data in tables and charts. Till now my learning process went very smooth, but now I'm a bit stuck. My pageview retrieves large amounts of data from a database and puts it in the context. The template then generates different html-tables. So far so good. Now I want to add different charts to the template. I manage to do this by defining <img src=".../> tags. The Matplotlib chart is generate in my chartview an returned via: response=HttpResponse(content_type='image/png') canvas.print_png(response) return response Now I have different questions: the data is retrieved twice from the database. Once in the pageview to render the tables, and again in the chartview for making the charts. What is the best way to pass the data, already in the context of the page to the chartview? I need a lot of charts, each with different datasets. I could make a chartview for each chart, but probably there is a better way. How do I pass the different dataset names to the chartview? Some charts have 20 datasets, so I don't think that passing these dataset parameters via the url (like: <imgm src="chart/dataset1/dataset2/.../dataset20/chart.png />) is the right way. Any advice?

    Read the article

  • Issues in Convergence of Sequential minimal optimization for SVM

    - by Amol Joshi
    I have been working on Support Vector Machine for about 2 months now. I have coded SVM myself and for the optimization problem of SVM, I have used Sequential Minimal Optimization(SMO) by Mr. John Platt. Right now I am in the phase where I am going to grid search to find optimal C value for my dataset. ( Please find details of my project application and dataset details here http://stackoverflow.com/questions/2284059/svm-classification-minimum-number-of-input-sets-for-each-class) I have successfully checked my custom implemented SVM`s accuracy for C values ranging from 2^0 to 2^6. But now I am having some issues regarding the convergence of the SMO for C 128. Like I have tried to find the alpha values for C=128 and it is taking long time before it actually converges and successfully gives alpha values. Time taken for the SMO to converge is about 5 hours for C=100. This huge I think ( because SMO is supposed to be fast. ) though I`m getting good accuracy? I am screwed right not because I can not test the accuracy for higher values of C. I am actually displaying number of alphas changed in every pass of SMO and getting 10, 13, 8... alphas changing continuously. The KKT conditions assures convergence so what is so weird happening here? Please note that my implementation is working fine for C<=100 with good accuracy though the execution time is long. Please give me inputs on this issue. Thank You and Cheers.

    Read the article

  • Difference dynamic static 2d array c++

    - by snorlaks
    Hello, Im using opensource library called wxFreeChart to draw some XY charts. In example there is code which uses static array as a serie : double data1[][2] = { { 10, 20, }, { 13, 16, }, { 7, 30, }, { 15, 34, }, { 25, 4, }, }; dataset->AddSerie((double *) data1, WXSIZEOF(dynamicArray)); WXSIZEOF ismacro defined like: sizeof(array)/sizeof(array[0]) In this case everything works great but in my program Im using dynamic arrays (according to users input). I made a test and wrotecode like below: double **dynamicArray = NULL; dynamicArray = new double *[5] ; for( int i = 0 ; i < 5 ; i++ ) dynamicArray[i] = new double[2]; dynamicArray [0][0] = 10; dynamicArray [0][1] = 20; dynamicArray [1][0] = 13; dynamicArray [1][1] = 16; dynamicArray [2][0] = 7; dynamicArray [2][1] = 30; dynamicArray [3][0] = 15; dynamicArray [3][1] = 34; dynamicArray [4][0] = 25; dynamicArray [4][1] = 4; dataset->AddSerie((double *) *dynamicArray, WXSIZEOF(dynamicArray)); But it doesnt work correctly. I mean point arent drawn. I wonder if there is any possibility that I can "cheat" that method and give it dynamic array in way it understands it and will read data from correct place thanks for help

    Read the article

  • SQL Cache Dependency not working with Stored Procedure

    - by pjacko
    Hello, I can't get SqlCacheDependency to work with a simple stored proc (SQL Server 2008): create proc dbo.spGetPeteTest as set ANSI_NULLS ON set ANSI_PADDING ON set ANSI_WARNINGS ON set CONCAT_NULL_YIELDS_NULL ON set QUOTED_IDENTIFIER ON set NUMERIC_ROUNDABORT OFF set ARITHABORT ON select Id, Artist, Album from dbo.PeteTest And here's my ASP.NET code (3.5 framework): -- global.asax protected void Application_Start(object sender, EventArgs e) { string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString; System.Data.SqlClient.SqlDependency.Start(connectionString); } -- Code-Behind private DataTable GetAlbums() { string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["UnigoConnection"].ConnectionString; DataTable dtAlbums = new DataTable(); using (SqlConnection connection = new SqlConnection(connectionString)) { // Works using select statement, but NOT SP with same text //SqlCommand command = new SqlCommand( // "select Id, Artist, Album from dbo.PeteTest", connection); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "dbo.spGetPeteTest"; System.Web.Caching.SqlCacheDependency new_dependency = new System.Web.Caching.SqlCacheDependency(command); SqlDataAdapter DA1 = new SqlDataAdapter(); DA1.SelectCommand = command; DataSet DS1 = new DataSet(); DA1.Fill(DS1); dtAlbums = DS1.Tables[0]; Cache.Insert("Albums", dtAlbums, new_dependency); } return dtAlbums; } Anyone have any luck with getting this to work with SPs? Thanks!

    Read the article

  • Starting out NLP - Python + large data set

    - by pencilNero
    Hi, I've been wanting to learn python and do some NLP, so have finally gotten round to starting. Downloaded the english wikipedia mirror for a nice chunky dataset to start on, and have been playing around a bit, at this stage just getting some of it into a sqlite db (havent worked with dbs in the past unfort). But I'm guessing sqlite is not the way to go for a full blown nlp project(/experiment :) - what would be the sort of things I should look at ? HBase (.. and hadoop) seem interesting, i guess i could run then im java, prototype in python and maybe migrate the really slow bits to java... alternatively just run Mysql.. but the dataset is 12gb, i wonder if that will be a problem? Also looked at lucene, but not sure how (other than breaking the wiki articles into chunks) i'd get that to work.. What comes to mind for a really flexible NLP platform (i dont really know at this stage WHAT i want to do.. just want to learn large scale lang analysis tbh) ? Many thanks.

    Read the article

  • batch_add_field_VBA

    - by Elaine Kuo
    I am unsure where goes wrong. Please kindly help and thanks. Public Sub AddField() Dim pApp As esriCatalogUI.IGxApplication Set pApp = esriArcCatalog.Application Dim pGxSelection As esriCatalog.IGxSelection Set pGxSelection = pApp.Selection Dim plist As esriCatalog.IEnumGxObject Set plist = pGxSelection.SelectedObjects Dim pGxObject As esriCatalog.IGxObject Dim pName As esriSystem.IName Dim pDS As esriGeoDatabase.IDataset Dim pGDSE As esriGeoDatabase.IGeoDatasetSchemaEdit Dim pStatusBar As esriSystem.IStatusBar Set pStatusBar = esriArcCatalog.Application.StatusBar Dim pFeatLyr As esriCarto.IFeatureLayer Dim pFeatureClass As esriGeoDatabase.IFeatureClass Dim pFeatureDataset As esriGeoDatabase.IFeatureDataset Dim pFieldEdit As esriGeoDatabase.IFieldEdit Set pGxObject = plist.Next Set pFeatureClass = pGxObject If pFeatureClass.Type = esriDTFeatureClass Then Set pFeatLyr = New FeatureLayer Set pFeatLyr.FeatureClass = pFeatureDataset.Dataset pFeatLyr.name = pGXDataset.Dataset.name End If 'Checks to make sure you have something selected If pGxObject Is Nothing Then MsgBox "You need to select the files", vbOKOnly, "Error" Exit Sub End If 'Runs a function to add field Dim pField1 As esriGeoDatabase.IFieldEdit ' Define the first new field. Set pField1 = New Field pField1.Name = "GID1" pField1.Type = esriFieldTypeInteger pField1.Length = 10 pFeatureClass.AddField pField1 'Loops through all selected files and preforms Do Until pGxObject Is Nothing If TypeOf pGxObject Is esriCatalog.IGxDataset Then Set pName = pGxObject.InternalObjectName Set pDS = pName.Open Set pGDSE = pDS With pGDSE If .CanAlterSpatialReference Then .AlterSpatialReference pFieldEdit End If End With End If pStatusBar.Message(0) = "Done: " & pGxObject.Name Set pGxObject = plist.Next Loop CleanUp: Set pFieldEdit = Nothing Set pGDSE = Nothing pStatusBar.Message(0) = "Done" End Sub

    Read the article

  • How to fill DataGridView from nested table oracle

    - by arkadiusz85
    I want to create my type: CREATE TYPE t_read AS OBJECT ( id_worker NUMBER(20), how_much NUMBER(5,2), adddate_r DATE, date_from DATE, date_to DATE ); I create a table of my type: CREATE TYPE t_tab_read AS TABLE OF t_read; Next step is create a table with my type: enter code hereCREATE TABLE Reading ( id_watermeter NUMBER(20) constraint Watermeter_fk1 references Watermeters(id_watermeter), read t_tab_read ) NESTED TABLE read STORE AS store_read ; Microsoft Visual Studio can not display this type in DataGridView. I use Oracle.Command: C# using Oracle.DataAccess; using Oracle.DataAccess.Client; private void button1_Click(object sender, EventArgs e) { try { //my working class to connect to database ConnectionClass.BeginConnection(); OracleDataAdapter tmp = new OracleDataAdapter(); tmp = ConnectionClass.ReadCommand(ReadClass.test()); DataSet dataset4 = new DataSet(); tmp.Fill(dataset4, "Read1"); dataGridView4.DataSource = dataset4.Tables["Read1"]; } catch (Exception o) { MessageBox.Show(o.Message); } public class ReadClass { public static OracleCommand test() { string sql = "select c.id_watermeter, a. from reading c , table (c.read) a where id_watermeter=1"; ConnectionClass.Command1= new OracleCommand(sql, ConnectionClass.Connection); ConnectionClass.Command1.CommandType = CommandType.Text; return ConnectionClass.Command1; } } I tray: string sql = "select r.id_watermeter, o.id_worker, o.how_much, o.adddate_r, o.date_from, o.date_to from reading r, table (r.read) o where r.id_watermeter=1" string sql = "select a.from reading c , Table (c.read) a where id_watermeter=1" string sql = "select a.id_worker, a.how_much, a.adddate_r, a.date_from, a.date_to from reading c , table (c.read) a where id_watermeter=1" string sql = "select c.id_watermeter, a. from reading c , table (c.read) a where id_watermeter=1" Error : Unsuported Oracle data type USERDEFINED encountered Sombady can help me how to fill DataGridView using data from nested table. I am using Oracle 10g XE

    Read the article

  • fill combobox value in datagridview based on other combobox in datagridview

    - by Purohit Raghu
    I m creating Web Application..in C# I have One Data grid view In that i Have 2 Combo box i m trying 2 bind second combo box based on first combo-box. in First Combo-box I have value Shirt,T shirt so i want if shirt is selected than second combo-box should have value Slim,Regular..and if T shirt Is selected than second Combo-box should have V neck and rounded color. i have different table for thirst and shirt type... I work fine for first time but when i goes on second row and change the combo box value than it will also change value of second combo box value of previous row as well .. Where i need to change to prevent change in upper row i have following code private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (dataGridView1.CurrentCell.ColumnIndex == 0) { ComboBox cbx = e.Control as ComboBox; cbx.SelectionChangeCommitted -= new EventHandler(cbx_SelectionChangeCommitted); cbx.SelectionChangeCommitted += new EventHandler(cbx_SelectionChangeCommitted); } } private void cbx_SelectionChangeCommitted(object sender, EventArgs e) { int selectedIndex = ((ComboBox)sender).SelectedIndex; if (selectedIndex == 1) //this condition is true if i have selected shirt from combobox1 { ShirtType(); } if (selectedIndex == 2) { Tshirtype(); } } void ShirtType() { try { string str; str = "select ShirtType_name,ShirtType_Id from ShirtType_master"; ds = new DataSet(); ds = cn.readdata(str); Type.DataSource = ds.Tables[0];//Type is Combobox name of Second Combobox Type.DisplayMember = ds.Tables[0].Columns[0].ToString(); ; Type.ValueMember = ds.Tables[0].Columns[1].ToString(); ; } catch (Exception ee) { } } void Tshirtype() { try { string str; str = "select TShirtType_name,TshirtType_Id from TshirtType_Master"; ds = new DataSet(); ds = cn.readdata(str); Type.DataSource = ds.Tables[0]; Type.DisplayMember = ds.Tables[0].Columns[0].ToString(); ; Type.ValueMember = ds.Tables[0].Columns[1].ToString(); ; }

    Read the article

  • Reading,Writing, Editing BLOBS through DataTables and DataRows

    - by Soham
    Consider this piece of code: DataSet ds = new DataSet(); SQLiteDataAdapter Da = new SQLiteDataAdapter(Command); Da.Fill(ds); DataTable dt = ds.Tables[0]; bool PositionExists; if (dt.Rows.Count > 0) { PositionExists = true; } else { PositionExists = false; } if (PositionExists) { //dt.Rows[0].Field<>("Date") } Here the "Date" field is a BLOB. My question is, a. Will reading through the DataAdapter create any problems later on, when I am working with BLOBS? More, specifically, will it read the BLOB properly? b. This was the read part.Now when I am writing the BLOB to the DB,its a queue actually. I.e I am trying to store a queue in MySQLite using a BLOB. Will Conn.ExecuteNonQuery() serve my purpose? c. When I am reading the BLOB back from the DB, can I edit it as the original datatype, it used to be in C# environment i.e { Queue - BLOB - ? } {C# -MySQL - C# } So in this context, Date field was a queue, I wrote it back as a BLOB, when reading it back, can I access it(and edit) as a queue? Thank You. Soham

    Read the article

  • vsts load test datasource issues

    - by ashish.s
    Hello, I have a simple test using vsts load test that is using datasource. The connection string for the source is as follows <connectionStrings> <add name="MyExcelConn" connectionString="Driver={Microsoft Excel Driver (*.xls)};Dsn=Excel Files;dbq=loginusers.xls;defaultdir=.;driverid=790;maxbuffersize=4096;pagetimeout=20;ReadOnly=False" providerName="System.Data.Odbc" /> </connectionStrings> the datasource configuration is as follows and i am getting following error estError TestError 1,000 The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library. Error details: ERROR [42000] [Microsoft][ODBC Excel Driver] Cannot update. Database or object is read-only. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed ERROR [42000] [Microsoft][ODBC Excel Driver] Cannot update. Database or object is read-only. I wrote a test, just to check if i could create an odbc connection would work and that works the test is as follows [TestMethod] public void TestExcelFile() { string connString = ConfigurationManager.ConnectionStrings["MyExcelConn"].ConnectionString; using (OdbcConnection con = new OdbcConnection(connString)) { con.Open(); System.Data.Odbc.OdbcCommand objCmd = new OdbcCommand("SELECT * FROM [loginusers$]"); objCmd.Connection = con; OdbcDataAdapter adapter = new OdbcDataAdapter(objCmd); DataSet ds = new DataSet(); adapter.Fill(ds); Assert.IsTrue(ds.Tables[0].Rows.Count > 1); } } any ideas ?

    Read the article

  • Setting Parameters from another Parameter In SSRS

    - by Mike
    I was able to get this working is SSRS 2008, but do to the fact that my company only has 2005 servers I need to downgrade the report to 2005. The idea is for a given person name there are two key fields EntityType and EntityId So I have a parameter from a dataset where the Label is the Name and the value is EntityType_EntityId I use the split function to take the left and right sides of from _ In 2008, I set the query parameters of the dataset to the split function and it works In 2005, I set the Default Value of each Report Parameters Now when I run the report and put textboxes showing the value of the parameters, the values are shown correctly but the query does not run. I am guessing that this is a lifecycle issue being Get Name Parameter Run Report THEN Set Parameters = Split of Name But the problem with that is the second time I run the report I should get result and I do not. Does anyone know what I am doing wrong. I guess I can pass in the underscore delimted string to the stored procedure and parse it there, but my question is can this be done in the report? Reason being other callers will pass in the parameters as two seperate values.

    Read the article

  • Problem in Adding Button in Dynamically created Gridview with Auto Generated Columns True

    - by Anuj Koundal
    Hi Guys I am using Gridview with auto columns true to Display data, I am using Dataset to bind Grid as Dataset gives me Crosstab/Pivot data on Dropdown's slected Index changed Here is the code I am using protected void ddl_SelectedIndexChanged(object sender, EventArgs e) { fillGridview(Convert.ToInt32(ddl.SelectedValue)); bindHeader(); } //===================//Bind GridColumns //================= void bindHeader() { GridViewRow headerRow; headerRow = gridDashboard.HeaderRow; foreach (GridViewRow grdRow in gridDashboard.Rows) { int count = grdRow.Cells.Count; int siteId=Convert.ToInt32(grdRow.Cells[4].Text); for (int j = 0; j < count; j++) { if (j >= 5) { int id=Convert.ToInt32(grdRow.Cells[j].Text); string headText =headerRow.Cells[j].Text.ToString(); string[] txtArray=headText.Split('-'); int stepId=Convert.ToInt32(txtArray[0]); //headerRow.Cells[j].Text = txtArray[1].ToString(); string HeadName = txtArray[1].ToString(); LinkButton lb = new LinkButton(); lb.Style.Add("text-decoration","none"); if (id > 0) { string Details = getDashBoardSiteStepDetails(id); lb.Text = Details; } else { lb.Text = " - "; } lb.CommandName = "HideColumn"; lb.CommandArgument = siteId.ToString() + "/" + stepId.ToString(); grdRow.Cells[j].Controls.Add(lb); } } } int cnt = headerRow.Cells.Count; for (int j = 0; j { if (j >= 5) { string hdText = headerRow.Cells[j].Text.ToString(); string[] txtArray = hdText.Split('-'); // int stepId = Convert.ToInt32(txtArray[0]); headerRow.Cells[j].Text = txtArray[1].ToString(); } } In above code I am trying to add button dynamically in each cell and button in text have text of that cell, IT works Great but when I click the link button created, link buttons Disappear and the original text of the cell Displays. please help I also want to create onclick of these link buttons Thanks

    Read the article

  • Sharepoint OLE DB - cannot insert records? "Field not updateable" error

    - by Pandincus
    I need to write a simple C# .NET application to retrieve, update, and insert some data in a Sharepoint list. I am NOT a Sharepoint developer, and I don't have control over our Sharepoint server. I would prefer not to have to develop this in a proper sharepoint development environment simply because I don't want to have to deploy my application on the Sharepoint server -- I'd rather just access data externally. Anyway, I found out that you can access Sharepoint data using OLE DB, and I tried it successfully using some ADO.NET: var db = DatabaseFactory.CreateDatabase(); DataSet ds = new DataSet(); using (var command = db.GetSqlStringCommand("SELECT * FROM List")) { db.LoadDataSet(command, ds, "List"); } The above works. However, when I try to insert: using (var command = db.GetSqlStringCommand("INSERT INTO List ([HeaderName], [Description], [Number]) VALUES ('Blah', 'Blah', 100)")) { db.ExecuteNonQuery(command); } I get this error: Cannot update 'HeaderName'; field not updateable. I did some Googling and apparently you cannot insert data through OLE DB! Does anyone know if there are some possible workarounds? I could try using Sharepoint Web Services, but I tried that initially and was having a heck of a time authenticating. Is that my only option?

    Read the article

  • reading dbase file without standard .dbf extension.

    - by Nathan W
    I am trying to read a file which is just a dbase file but without the standard extension the file is something like: Test.Dat I am using this block of code to try and read the file: string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Temp;Extended Properties=dBase III"; OleDbConnection dBaseConnection = new OleDbConnection(ConnectionString); dBaseConnection.Open(); OleDbDataAdapter oDataAdapter = new OleDbDataAdapter("SELECT * FROM Test", ConnectionString); DataSet oDataSet = new DataSet(); oDataAdapter.Fill(oDataSet);//I get the error right here... DataTable oDataTable = oDataSet.Tables[0]; foreach (DataRow dr in oDataTable.Rows) { Console.WriteLine(dr["Name"]); } Of course this crashes because it can't find the dbase file called test, but if I rename the file to Test.dbf it works fine. I can't really rename the file all the time because a third party application uses it as its file format. Does anyone know a way to read a dbase file without a standard extension in C#. Thanks.

    Read the article

  • Using LINQ to SQL and chained Replace

    - by White Dragon
    I have a need to replace multiple strings with others in a query from p in dx.Table where p.Field.Replace("A", "a").Replace("B", "b").ToLower() = SomeVar select p Which provides a nice single SQL statement with the relevant REPLACE() sql commands. All good :) I need to do this in a few queries around the application... So i'm looking for some help in this regard; that will work as above as a single SQL hit/command on the server It seems from looking around i can't use RegEx as there is no SQL eq Being a LINQ newbie is there a nice way for me to do this? eg is it possible to get it as a IQueryable "var result" say and pass that to a function to add needed .Replace()'s and pass back? Can i get a quick example of how if so? EDIT: This seems to work! does it look like it would be a problem? var data = from p in dx.Videos select p; data = AddReplacements(data, checkMediaItem); theitem = data.FirstOrDefault(); ... public IQueryable<Video> AddReplacements(IQueryable<Video> DataSet, string checkMediaItem) { return DataSet.Where(p => p.Title.Replace(" ", "-").Replace("&", "-").Replace("?", "-") == checkMediaItem); }

    Read the article

  • dynamically created radiobuttonlist

    - by Janet
    Have a master page. The content page has a list with hyperlinks containing request variables. You click on one of the links to go to the page containing the radiobuttonlist (maybe). First problem: When I get to the new page, I use one of the variables to determine whether to add a radiobuttonlist to a placeholder on the page. I tried to do it in page)_load but then couldn't get the values selected. When I played around doing it in preInit, the first time the page is there, I can't get to the page's controls. (Object reference not set to an instance of an object.) I think it has something to do with the MasterPage and page content? The controls aren't instantiated until later? (using vb by the way) Second problem: Say I get that to work, once I hit a button, can I still access the passed request variable to determine the selected item in the radiobuttonlist? Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit 'get sessions for concurrent Dim Master As New MasterPage Master = Me.Master Dim myContent As ContentPlaceHolder = CType(Page.Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder) If Request("str") = "1" Then Dim myList As dsSql = New dsSql() ''''instantiate the function to get dataset Dim ds As New Data.DataSet ds = myList.dsConSessionTimes(Request("eid")) If ds.Tables("conSessionTimes").Rows.Count > 0 Then Dim conY As Integer = 1 CType(myContent.FindControl("lblSidCount"), Label).Text = ds.Tables("conSessionTimes").Rows.Count.ToString Sorry to be so needy - but maybe someone could direct me to a page with examples? Maybe seeing it would help it make sense? Thanks....JB

    Read the article

  • Extract enumeration data from .XSD file

    - by Ram
    Hi, I am trying to read enum from a XSD file. The schema is as follows <xs:schema id="ShipReports-v1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="unqualified" elementFormDefault="qualified" msdata:IsDataSet="true"> <xs:simpleType name="Type"> <xs:restriction base="xs:string"> <xs:enumeration value="Op1" /> <xs:enumeration value="Op2" /> <xs:enumeration value="Op3" /> </xs:restriction> </xs:simpleType> </xs:schema> I also tried using this but I am getting list item count as Zero. Following is the code I am using DataSet _sR = new DataSet(); _sR.ReadXmlSchema(assembly.GetManifestResourceStream("v1.xsd")); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(_sR.GetXml()); XmlNamespaceManager xMan = new XmlNamespaceManager(xDoc.NameTable); xMan.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); XmlNodeList xNodeList = xDoc.SelectNodes( "//xs:schema/xs:simpleType[@name='Type']/xs:enumeration", xMan); string[] enumVal = new string[xNodeList.Count]; int ctr = 0; foreach (XmlNode xNode in xNodeList) { enumVal[ctr] = xNode.Attributes["value"].Value; ctr++; }

    Read the article

  • Design suggestion for expression tree evaluation with time-series data

    - by Lirik
    I have a (C#) genetic program that uses financial time-series data and it's currently working but I want to re-design the architecture to be more robust. My main goals are: sequentially present the time-series data to the expression trees. allow expression trees to access previous data rows when needed. to optimize performance of the data access while evaluating the expression trees. keep a common interface so various types of data can be used. Here are the possible approaches I've thought about: I can evaluate the expression tree by passing in a data row into the root node and let each child node use the same data row. I can evaluate the expression tree by passing in the data row index and letting each node get the data row from a shared DataSet (currently I'm passing the row index and going to multiple synchronized arrays to get the data). Hybrid: an immutable data set is accessible by all of the expression trees and each expression tree is evaluated by passing in a data row. The benefit of the first approach is that the data row is being passed into the expression tree and there is no further query done on the data set (which should increase performance in a multithreaded environment). The drawback is that the expression tree does not have access to the rest of the data (in case some of the functions need to do calculations using previous data rows). The benefit of the second approach is that the expression trees can access any data up to the latest data row, but unless I specify what that row is, I'll have to iterate through the rows and figure out which one is the last one. The benefit of the hybrid is that it should generally perform better and still provide access to the earlier data. It supports two basic "views" of data: the latest row and the previous rows. Do you guys know of any design patterns or do you have any tips that can help me build this type of system? Should I use a DataSet to hold and present the data, or are there more efficient ways to present rows of data while maintaining a simple interface? FYI: All of my code is written in C#.

    Read the article

  • C# and SQL - sub select from a table parameter

    - by Dr.HappyPants
    Below is a code snippet for passing a table as a parameter to a query that can be used in Sql Server 2008. I'm confused though about the "SELECT id.custid FROM @custids id". Why does it use id.custid and @custids id...? private static void datatable_example() { string [] custids = {"ALFKI", "BONAP", "CACTU", "FRANK"}; DataTable custid_list = new DataTable(); custid_list.Columns.Add("custid", typeof(String)); foreach (string custid in custids) { DataRow dr = custid_list.NewRow(); dr["custid"] = custid; custid_list.Rows.Add(dr); } using(SqlConnection cn = setup_connection()) { using(SqlCommand cmd = cn.CreateCommand()) { cmd.CommandText = @"SELECT C.CustomerID, C.CompanyName FROM Northwind.dbo.Customers C WHERE C.CustomerID IN (SELECT id.custid FROM @custids id)"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@custids", SqlDbType.Structured); cmd.Parameters["@custids"].Direction = ParameterDirection.Input; cmd.Parameters["@custids"].TypeName = "custid_list_tbltype"; cmd.Parameters["@custids"].Value = custid_list; using (SqlDataAdapter da = new SqlDataAdapter(cmd)) using (DataSet ds = new DataSet()) { da.Fill(ds); PrintDataSet(ds); } } }

    Read the article

  • C# HTML tags inside GridView

    - by Geo Ego
    I have a SharePoint web part that I wrote in C# which is used to display SQL Server data based on user selections. I pull the data with a DataReader, fill a DataSet with it, and set that DataSet as the DataSource in a GridView and add that control to my page. The only problem I'm facing is that line breaks in the data fields are not being rendered at all. I'm simply getting a block of text that ignores the breaks that are present in the database when it's rendered to HTML. I tried a regex: Regex rgx = new Regex("\n"); string inputStr = Convert.ToString(dr[x]); string outputStr = rgx.Replace(inputStr, "<br />"); newRow[ds3.Tables["Bobst Specs 3"].Columns[x]] = outputStr; While that does detect and replace the newlines, I merely get the text "" with no line breaks. I also tried changing my SQL query to something along the lines of: SELECT REPLACE (fldCustomerName, '. ', '.' + @NewLineChar) This apparently renders more newlines. I can see that they are present, because if I also insert the regex they are affected, but do not create line breaks. I'm not sure how to replace these, and what with, to get the lines to actually break.

    Read the article

  • Accessing an excel file throws OleDbException but keeps handle on file

    - by Jonn
    Really odd that I'd get an oledbexception but turns out that the file's handle is still with the original file. I've been searching through google and keep finding the same problem but no solutions. Connection String: "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + filePath + ";" + "Extended Properties=Excel 8.0;"; Note that it works on every other file except a particular excel file. Exception: System.Data.OleDb.OleDbException: No error information available: E_UNEXPECTED(0x8000FFFF). And then I have exception handling like this: try { IEnumerable<string> worksheetNames = GetWorkbookWorksheetNames(connString); DataSet ds; foreach (string worksheetName in worksheetNames) { OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM [" + worksheetName + "]", connString); ds = new DataSet(); dataAdapter.Fill(ds, "ExcelInfo"); DataTable dt = ds.Tables["ExcelInfo"]; entityList.AddRange(GetDataFromDataTable(dt, worksheetName)); } } catch (OleDbException ex) { File.Move(filePath, filePath + ".invalidFormat.xls"); } Has anyone else encountered this behavior? And I'm not sure how to handle an error that keeps the handle on the file I'm supposed to process. It sort of freezes everything in place.

    Read the article

< Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >