Search Results

Search found 1109 results on 45 pages for 'ado'.

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

  • Retrive data from two tables in asp.net mvc using ADO.Net Entity Framework

    - by user192972
    Please read my question carefully and reply me. I have two tables as table1 and table2. In table1 i have columns as AddressID(Primary Key),Address1,Address2,City In table2 i have columns as ContactID(Primary Key),AddressID(Foriegn Key),Last Name,First Name. By using join operation i can retrive data from both the tables. I created a Model in my MVC Application.I can see both the tables in enitity editor. In the ViewData folder of my solution explorer i created two class as ContactViewData.cs and SLXRepository.cs In the ContactViewData.cs i have following code public IEnumerable<CONTACT> contacts { get; set; } In the SLXRepository.cs i have following code public IEnumerable<CONTACT> GetContacts() { var contact = ( from c in context.CONTACT join a in context.ADDRESS on c.ADDRESSID equals a.ADDRESSID select new { a.ADDRESS1, a.ADDRESS2, a.CITY, c.FIRSTNAME, c.LASTNAME } ); return contact; } I am getting the error in return type Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists (are you missing a cast?)

    Read the article

  • ASP.NET MVC & ADO.NET Entity Framework clientside validation

    - by JK
    Using aspnet mvc2 with the model auto-generated by entity framework: Is it possible to tell entity framework to auto-annotate all fields? eg: If database field says not null then add [Required] If DB field is a nvarchar(x) then add [StringLength(x)] And so on? What if the field name contains the string "email" eg CustomerEmail - can I get EF to auto-annotate that with an appropriate annotation ([Regex()] maybe) As I understand it, if the model fields are annotated, and I use both Html.ValidationMessageFor() and use if (ModelState.IsValid) in my controller, then that is all I need to do to have basic clientside input validation working? Thanks

    Read the article

  • C# problem with ADO

    - by ahmed
    When i use the following code, i get this error : "OleDbexception Syntax error in INSERT INTO statement. plz help me! { // add the new username System.Data.OleDb.OleDbCommandBuilder cb; cb = new System.Data.OleDb.OleDbCommandBuilder(da); DataRow dRow = cPD_DatabaseDataSet.Tables["users_table"].NewRow(); dRow[0] = this.textBox_add_user.Text ; dRow[1] = this.textBox_password.Text ; cPD_DatabaseDataSet.Tables["users_table"].Rows.Add(dRow); //add new record cb.GetUpdateCommand(); cb.GetInsertCommand(); //save new recode into the Access file da.Update(cPD_DatabaseDataSet, "users_table"); //clear textboxes this.textBox_add_user.Text = ""; this.textBox_password.Text = ""; this.textBox_re_password.Text = ""; } catch (System.Data.OleDb.OleDbException exp) { //close the connection this.con.Close(); MessageBox.Show(exp.ToString()); }`

    Read the article

  • delphi Ado update insert betwen 2 records

    - by user315957
    i nead to update recordes from one table to the other (this for the master Table and f«the same for the DetailTable. first a posicion the record of the record´s of the table i whant to copy update from: Tabelamestre(Local_deste_cliente) (1 record ) NInterv.text:=dbedit1.text; Begin with ADOTable_casa do Begin Close; SQL.Clear; SQL.Add('SELECT * from Vibrometria_'); SQL.Add('Where numeracao LIKE ''%'+NInterv.text ); Open; end; end now i need to update/insert the record´s from Vibrometria := Local_deste_cliente (TADOTABLE) Now i nead to get the record above and do the same for the 2 detail tables Vibrometria_Sub (J) := Tabeladetail (Variaveis_neste_local). ((J) Records and i stil have another table thar get a master record from (K) Tabeladetail (Variaveis_neste_local) Vibrometria_Sub1 (K) := Tabeladetail1(Variaveis_neste_local1). ((k) Records lest´s say i nead to update 1 to N starting in the first table!!!!!!!! is there a fast solucion for this!!!!!! Thanks

    Read the article

  • Visual Basic 6 ADO Update question...

    - by Dave
    Hi, I've been working with a Legacy application which interacts with a database through ADODB, and most of the changes to records follow a fairly straightforward pattern of: Create a Recordset from a query Make various change to the recordset call .Update on the recordset. What I'm wondering is, with ADODB recordsets, is there anyway to extract the 'changes'. The logic which changes the recordset is scattered about, and all I need is the changes, not how it was changed... Any suggestions for tracking changes in a recordset (in code, a trigger on the DB or similar is no use here) Thanks in advance

    Read the article

  • Ado.net entity model problem

    - by ognjenb
    public ActionResult Index() { using (testEntities korisnici = new testEntities()) { my_aspnet_users user = new my_aspnet_users(); user = from i in korisnici.my_aspnet_users select i; return View(user); } } Error: Cannot implicitly convert type 'System.Linq.IQueryable' to 'MyApp.Models.my_aspnet_users'. An explicit conversion exists (are you missing a cast?)

    Read the article

  • ADO Exception in HQL query

    - by Yoav
    I have 2 classes: Project and DataStructure. Class Project contains member List<DataStructure. My goal is to load a Project and all its DataStructures in one call. public class Project { public virtual string Id { get { } set { } } public virtual string Name { get { } set { } } public virtual ISet<DataStructure> DataStructures { get { } set { } } } public class DataStructure { public virtual string Id { get { } set { } } public virtual string Name { get { } set { } } public virtual string Description { get { } set { } } public virtual Project Project { get { } set { } } public virtual IList<DataField> Fields { get { } set { } } } Note that DataStructure also contains a list of class DataField but I don’t want to load these right now. Mapping in Fluent NHibernate: public class ProjectMap : ClassMap<Project> { public ProjectMap() { Table("PROJECTS"); Id(x => x.Pk, "PK"); Map(x => x.Id, "ID"); Map(x => x.Name, "NAME"); HasMany<DataStructure>(x => x.DataStructures).KeyColumn("FK_PROJECT"); } } public class DataStructureMap : ClassMap<DataStructure> { public DataStructureMap() { Table("DATA_STRUCTURES"); Map(x => x.Id, "ID"); Map(x => x.Name, "NAME"); Map(x => x.Description, "DESCRIPTION"); References<Project>(x => x.Project, "FK_PROJECT"); HasMany<DataField>(x => x.Fields).KeyColumn("FK_DATA_STRUCTURE"); } } This is my query: using (ISession session = SessionFactory.OpenSession()) { IQuery query = session.CreateQuery("from Project pr left join pr.DataStructure"); project = query.List<Project>(); } query.List() returns this exception: NHibernate.Exceptions.GenericADOException: Could not execute query[SQL: SQL not available] ---> System.ArgumentException: The value "System.Object[]" is not of type "Project" and cannot be used in this generic collection.

    Read the article

  • Insert problem using ADO with classic ASP

    - by Kemal Akcali
    ' Setting variables Dim con, sql_insert, data_source data_source = "project_db" sql_insert = "insert into cart ( UserID,Count,ProductName,ProductDescription,ProductPrice) values ('"&user_id&"','"&count&"','"&product_name&"','"&product_description&"','"&product_price&"')" ' Creating the Connection Object and opening the database Set con = Server.CreateObject("ADODB.Connection") con.Open data_source ' Executing the sql insertion code con.Execute sql_insert ' Done. Now Close the connection con.Close Set con = Nothing AS you can see , it is a simple code . and it worked in my local host for 5 or 6 times. but now it didn't work. What's the problem ? I think , it's about my database or memory. i setup 2 different iis in 2 different computer and they behave same... please help.. Thanks

    Read the article

  • Read [for xml auto, elements] into DataTable in ADO.NET

    - by ihorko
    Hello All! I have MS SQL Server stored procedure that returns XML (it uses SELECT with for xml auto, elements) I tried read it into DataTable: DataTable retTable = new DataTable(); SqlCommand comm = new SqlCommand("exec MySP", connection); SqlDataAdapter da = new SqlDataAdapter(comm); connection.Open(); da.Fill(retTable); but retTable contains 12 rows with separated full xml thar SQL Server returns. How can I read that XML from DB into DataTable object? Thanks!

    Read the article

  • Cannot locate record in delphi ADO query

    - by Danatela
    I can't locate any record in TADOQuery using PK. First, I was trying to use standard Locate method: PPUQuery.Locate('ID', SpPlansQuery['PPONREC'], []); It always returns False, but manual search (passing the whole query matching ID with given PPONREC which is really slow) finds the desired row. I tried using loPartialKey and switched CursorLocation of query to clUseServer, but it didn't help. Next, I tried to filter my PPUQuery: PPUQuery.Filter := 'ID = ' + VarToStr(SpPlansQuery['PPONREC']); PPUQuery.Filtered := True; PPUQuery.First; But after that the PPUQuery.Eof is True and PPUQuery.RecordCount equals 0. Underlying database is Oracle 9 and the ID is of type INTEGER and is PK of table TPORDER_CMK. PPUQuery.SQL is: SELECT tp.*, la.*, lm.*, ld.*, ld1.*, to_cmk.* FROM ppu_plan.tporder_cmk tp JOIN PPU_PLAN.LARTICLES la ON TP.ARTICLE = LA.ID JOIN PPU_PLAN.LMATERIAL lm ON TP.MATERIAL = lm.id JOIN PPU_PLAN.LCADEP ld ON TP.CADEP = LD.ID JOIN PPU_PLAN.LCADEP ld1 ON TP.PRODUCER = LD1.ID JOIN PPU_PLAN.TORDER_CMK to_cmk ON TP.order_id=TO_cmk.ID WHERE TP.PLAN_ID = :pplan_id What should I try next and how to solve this problem?

    Read the article

  • what does this ADO OPEN Method do?

    - by every_answer_gets_a_point
    in plain english can you explain to me what happens here: rs.Open "batchinfo", oConn, adOpenKeyset, adLockOptimistic, adCmdTable what i need to do is to be able to insert values into a table called batchinfo. would this be the best way to do an OPEN? the only thing i would be doing is inserting values.

    Read the article

  • Unable to determine the provider name for connection of type 'System.Data.SqlServerCe.SqlCeConnectio

    - by Hobbes1312
    Hi, i am using the Ado.Net Entity Framework with Code Only (Tutorial at: ADO.NET team blog) and i want to be as much database independent as possible. In my first approach i just want to go for Sql Express and Sql Compact databases. With Sql Express everthing works fine but with Sql Compact i get the exception mentioned in my question. Does anybody knows if it is possible to connect to Sql Compact with the Code Only approach? (with a generated .edmx file for a Sql Compact database everthing works fine, but i want to use code only!) Here is some code: My Class which is building the DataContext: public class DataContextBuilder : IDataContextBuilder { private readonly DbProviderFactory _factory; public DataContextBuilder(DbProviderFactory factory) { _factory = factory; } #region Implementation of IDataContextBuilder public IDataContext CreateDataContext(string connectionString) { var builder = new ContextBuilder<DataContext>(); RegisterConfiguration(builder); var connection = _factory.CreateConnection(); connection.ConnectionString = connectionString; var ctx = builder.Create(connection); return ctx; } #endregion private void RegisterConfiguration(ContextBuilder<DataContext> builder) { builder.Configurations.Add(new PersonConfiguration()); } } The line var ctx = builder.Create(connection); is throwing the exception. The IDataContext is just a simple Interface for the ObjectContext: public interface IDataContext { int SaveChanges(); IObjectSet<Person> PersonSet { get; } } My connection string is configured in the app.config: <connectionStrings> <add name="CompactConnection" connectionString="|DataDirectory|\Test.sdf" providerName="System.Data.SqlServerCe.3.5" /> </connectionStrings> And the build action is started with var cn = ConfigurationManager.ConnectionStrings["CompactConnection"]; var factory = DbProviderFactories.GetFactory(cn.ProviderName); var builder = new DataContextBuilder(factory); var context = builder.CreateDataContext(cn.ConnectionString);

    Read the article

  • ASP Classic, SQL 2008, XML Output, and DSN vs DSN-Less Produces Chinese Letters

    - by RoLYroLLs
    I've been having a problem for the past month and can't seem to figure out what is wrong. Here's the setup and a little background. Background: I have a web-host who was running my website on Windows Server 2003 and SQL Server 2000. One of my webpages returned a result set from a stored procedure from the SQL server as xml. Below is the code: Stored Procedure: select top 10 1 as tag , null as parent , column1 as [item!1!column1!element] , column2 as [item!1!column2!element] from table1 for XML EXPLICIT ASP Page: index.asp Call OpenConn Set cmd = Server.CreateObject("ADODB.Command") With cmd .ActiveConnection = dbc .CommandText = "name of proc" .CommandType = adCmdStoredProc .Parameters.Append .CreateParameter("@RetVal", adInteger, adParamReturnValue, 4) .Parameters.Append .CreateParameter("@Level", adInteger, adParamInput, 4, Level) End With Set rsItems = Server.CreateObject("ADODB.Recordset") With rsItems .CursorLocation = adUseClient .CursorType = adOpenStatic .LockType = adLockBatchOptimistic Set .Source = cmd .Open Set .ActiveConnection = Nothing End With If NOT rsItems.BOF AND NOT rsItems.EOF Then OutputXMLQueryResults rsItems,"items" End If Set rsItems = Nothing Set cmd = Nothing Call CloseConn Sub OpenConn() strConn = "Provider=SQLOLEDB;Data Source=[hidden];User Id=[hidden];Password=[hidden];Initial Catalog=[hidden];" Set dbc = Server.CreateObject("ADODB.Connection") dbc.open strConn End Sub Sub CloseConn() If IsObject(dbc) Then If dbc.State = adStateOpen Then dbc.Close End If Set dbc = Nothing End If End Sub Sub OutputXMLQueryResults(RS,RootElementName) Response.Clear Response.ContentType = "text/xml" Response.Codepage = 65001 Response.Charset = "utf-8" Response.Write "" Response.Write "" While Not RS.EOF Response.Write RS(0).Value RS.MoveNext WEnd Response.Write "" Response.End End Sub Present: All was working great, until my host upgraded to Windows Server 2008 and SQL Server 2008. All of the sudden I was getting results like this: From Browser: From View Source: However, I found that if I use a DSN connection strConn = "DSN=[my DSN Name];User Id=[hidden];Password=[hidden];Initial Catalog=[hidden];" it works perfectly fine! My current host is not going to support DSN any longer, but that's out of scope for this issue. Someone told me to use an ADO.Stream object instead of a Recordset object, but I'm unsure how to implement that. Question: Has anyone run into this and found a way to fix it? What about that ADO.Stream object, can someone help me with a sample that would fit my code?

    Read the article

  • Mysql latin1 turkish data and delphi 2010 utf8

    - by sabri.arslan
    Hello, I have tables collating latin1_general_ci and have turkish character values. And i can use this data on delphi 7+zeos with no problem. but i want to upgrade my delphi to 2010 version but zeos too slow as i saw. so i want to use odbc+ado or dbexpress solution. dbexpress solution works fine , display my data as entered and write as entered table without any change to column charset. but dbexpress has problems as i saw. for example when i select * from table which has column types as varchar,decimal,int,tinyint,text give av errors on xp systems. vista and 7 does not give any error and work fine(not fully tested). ado solution(dbgo) works fine but its not show my data as entered.its want everything be utf. but i don't want to convert my data to utf before test everything. how can i see my data as entered and write client side utf and store latin1(as zeos or dbexpress do). i was tried many other options. eg. mysql side collation and charset parameters. sorry for my bad english. i hope someone understand me. thanks.

    Read the article

  • How to read a database record with a DataReader and add it to a DataTable

    - by Olga
    Hello I have some data in a Oracle database table(around 4 million records) which i want to transform and store in a MSSQL database using ADO.NET. So far i used (for much smaller tables) a DataAdapter to read the data out of the Oracle DataBase and add the DataTable to a DataSet for further processing. When i tried this with my huge table, there was a outofmemory exception thrown. ( I assume this is because i cannot load the whole table into my memory) :) Now i am looking for a good way to perform this extract/transfer/load, without storing the whole table in the memory. I would like to use a DataReader and read the single dataRecords in a DataTable. If there are about 100k rows in it, I would like to process them and clear the DataTable afterwards(to have free memory again). Now i would like to know how to add a single datarecord as a row to a dataTable with ado.net and how to completly clear the dataTable out of memory: My code so far: Dim dt As New DataTable Dim count As Int32 count = 0 ' reads data records from oracle database table' While rdr.Read() 'read n records and add them to a dataTable' While count < 10000 dt.Rows.Add(????) count = count + 1 End While 'transform data in the dataTable, and insert it to the destination' ' flush the dataTable after insertion' count = 0 End While Thank you very much for your response!

    Read the article

  • How to execute stored procedure from Access using linked tables

    - by webworm
    I have an Access 2003 database that connects to a SQL Server 2008 box via ODBC. The tables from SQL Server are connected as linked tables in Access. I have a stored procedure on the SQL Server that I am trying to execute via ADO code. The problem I have is that Access cannot seem to find the procedure. What do I have to do within Access to be able to execute this stored procedure? Some facts ... The stored procedure in question accepts one parameter which is an integer. The stored procedure returns a recordset which I am hoping to use as the datasource for a ListBox. Here is my ADO code in Access ... Private Sub LoadUserCaseList(userID As Integer) Dim cmd As ADODB.Command Set cmd = New ADODB.Command cmd.ActiveConnection = CurrentProject.Connection cmd.CommandType = adCmdStoredProc cmd.CommandText = "uspGetUserCaseSummaryList" Dim par As New ADODB.Parameter Set par = cmd.CreateParameter("userID", adInteger) cmd.Parameters.Append par cmd.Parameters("userID") = userID Dim rs As ADODB.Recordset Set rs = cmd.Execute() lstUserCases.Recordset = rs End Sub The error I get is "the microsoft jet database engine cannot find the input table or query "uspGetUserCaseSummaryList".

    Read the article

  • How to make a Stored Procedure that takes in XML and uses that xml as an Update + call this stored p

    - by chobo2
    Hi I am using ms sql server 2005 and I want to do a mass update. I am thinking that I might be able to do it with sending an xml document to a stored procedure. So I seen many examples on how to do it for insert CREATE PROCEDURE [dbo].[spTEST_InsertXMLTEST_TEST](@UpdatedProdData XML) AS INSERT INTO dbo.UserTable(CreateDate) SELECT @UpdatedProdData.value('(/ArrayOfUserTable/UserTable/CreateDate)[1]', 'DATETIME') But I am not sure how it would look like for an update. I am also unsure how do I pass in the xml through ado.net? Do I pass it as a string through a parameter or what? I know sqlDataApater has a batch update method but I am using linq to sql. So I rather keep using it. So if this works I would be able to grab all records with linq to sql and have them as objects. Then manipulate the objects and use xml seralization. Finally I could just use ado.net simple to send the xml to the server. This might be slower then the sqlDataAdapter but I am willing to take that hit if I can keep using objects.

    Read the article

  • Delphi 2010 Calcualted Column In DBGrid

    - by Ken Lange
    I have a Delphi 2010 ADO program that has a DBGrid. Its dataset selects from an Access query. The query has a column defined as, CStr(Amount*UnitCount)+" "+Unit. The query works fine in Acecss. But the DBgrid refuses to show the values for this column

    Read the article

  • Are there any reserved words in SQLite?

    - by DanM
    Three questions about reserved words: Are there any reserved words in SQLite? If so, what are they? If there are reserved words, is the correct syntax for using one of them as a column or table name still to surround it with brackets? E.g., [User] or [Name]? Are there any implications with using words that are reserved in other flavors of SQL (e.g., SQLServer) but not reserved in SQLite when using ADO.NET to query a SQLite database?

    Read the article

  • How to get identities of inserted data records using SQL bulk copy

    - by Olga
    Hello I have a ADO.NET dataTable with about 100.000 records. In this table there is a column "xyID" which has no values in it, because they are generated by insertion into my MSSQL Database. Now i have the problem, that i need this IDs for other processes. I am looking for a way to bulk copy this dataTable into the MSSQL database, and within the same "step" to "fill" my dataTable with the generated IDs. Thank you for your answers!

    Read the article

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