w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
I want to get updated records from web sql server database into local database table through Store Procedure
Check linked server. http://www.jensbits.com/2010/11/10/create-linked-server-sql-server-2008/ after link the web server in to your local server, can access data easily.

Categories : Sql Server

Sqlite database unable to delete objects, failing with message "Cannot store type: "
Rather than use: public int DeleteItem<T>(int id) where T : IBusinessEntity, new() { lock (locker) { #if NETFX_CORE return Delete(new T() { ID = id }); #else return Delete<T> (new T () { ID = id }); #endif } } Use this instead: public int Delete(object objectToDelete) { var map = GetMapping(objectToDelete.GetType()); var pk = map.PK; if (pk == null) { throw new NotSupportedException("Cannot delete " + map.TableName + ": it has no PK"); } var q = string.Format("delete from "{0}" where "{1}" = ?", map.TableName, pk.Name); return Execute(q, pk.GetValue(objectToDelete)); }

Categories : Sqlite

I can only store numbers in the database, a simple shoutbox in php
See if this helps: function postMessage($message){ mysqli_query(connectdb(), "INSERT INTO messages (message) VALUES ("'".mysqli_real_escape_string($message)."'")"); } // connectdb(); // this is probably not needed since this function // is called in postMessage function if (isset($_POST['message'])){ postMessage($_POST['message']); }

Categories : PHP

Store meta information as a simple Enum or in database?
IMO, you should not choose one over the other, but instead have both. The enum will help keep your Java code clean, and the table will help keep that data organized. It would be good to have a separate (master) table for that type of information. And the other tables can reference it as a foreign key. With that you will have a central location for possible values. You wouldn't have to go every where looking for all the possible values. You can create an enum representing that (master) table. And it can be used as field type if you create entities for other tables. You can see this for an example. Also (optionally) you could valid the enum with table content at application start, to make sure the enum stays in sync with the table, in case new values or added or some existing ones are upd

Categories : Java

Join Remote database table with my Local database table in SQL Server 2012
You should try using the SQL Server Import and Export Wizard: http://msdn.microsoft.com/en-us/library/ms140052.aspx If possible you could export the data from one server and import it to the other using the wizard. If this is not possible then you could export to a file from one server, and then import from a file onto the other.

Categories : SQL

Cannot convert IQueryable> to return type IEnumerable
It looks like you want to select items from a collection within a collection and flatten the result into a single sequence. Conceptually, something like: If that's the case, you're looking for the SelectMany method: var propertyNames = _dbSis.ModuleKinds .Where(t => t.PerTypeConfigurationId == configurationId) .SelectMany(x => x.PerTypeConfiguration.Properties) .Select(z => z.Name);

Categories : C#

Select random user from database table and store in another table
You can change your first query to exclude users present in the other table with NOT EXISTS. http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html It should look like this SELECT userid, firstname, surname, email FROM users WHERE NOT EXISTS (SELECT * FROM winners WHERE users.userid = winners.userid) ORDER BY RAND() LIMIT 1; Also your code didn't work because it only had one loop because of the limit 1

Categories : PHP

What is the best way to store a field that supports markdown in my database when I need to render both HTML and "simple text" views?
You need to store your data in a canonical format. That is, in one true format within your database. It sounds like this format should be a text column that contains markdown. That answers the database-design part of your question. Then, depending on what format you need to export, you should take the canonical format and convert it to the required output format. This might be just outputting the markdown text, or running it through some sort of parser to remove the markdown or convert it to HTML.

Categories : Javascript

Entity Framework Code First: Computed property of type Type causes ArgumentNullException on Update-Database
Use NotMappedAttribute: Denotes that a property or class should be excluded from database mapping.

Categories : C#

Why am I getting this type compatibility error with Database.PostgreSQL.Simple?
The PostgreSQL count() functions returns a Bigint type, see http://www.postgresql.org/docs/9.2/static/functions-aggregate.html Bigint are 8 bytes see http://www.postgresql.org/docs/9.2/static/datatype-numeric.html Haskell int is ~ 2**29 which implies it a 4 byte integer. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Int.html Then its normal that PostgreSQL or its API will not do an implicit downwards conversion in precision. So use a Haskell int64 type or cast count(*) to integer.

Categories : Postgresql

The ViewData item that has the key 'category' is of type 'System.String' but must be of type 'IEnumerable'
In post, if ModelState is invalid, you return view. But you fill categories select list only in get request, you should do that in post too [HttpPost] public ActionResult Create(Contact contact) { try { if (ModelState.IsValid) { db.Contacts.Add(contact); db.SaveChanges(); return RedirectToAction("Index"); } } catch (DataException) { //Log the error (add a variable name after DataException) ModelState.AddModelError("", "Unable to save changes, Try again."); } IEnumerable<SelectListItem> items = db.Catagorys .Select(c => new SelectListItem { Text = c.CatagoryName }); return View(contact); } And of course, it will be great if you create CreateContac

Categories : Asp Net Mvc

Entity Framework Code First Table-Per-Type Inheritance include base type
The answer was to remove the abstract keyword from the Base class (Person): FROM: public abstract class Person { public string FirstName { get; set; } public string LastName { get; set; } public Training Training { get; set; } } TO: public class Person { public string FirstName { get; set; } public string LastName { get; set; } public Training Training { get; set; } }

Categories : C#

Does a IEnumerable store objects after use
It depends on the implementation. It is not against the specification for an IEnumerable to store the values in the sequence that it represents. In fact, a List<T> is an IEnumerable<T> that does exactly that! Now, for the IEnumerable that you have, it will not store the objects after it returns them. DbDataReaders merely stream the results to you, and yield returning them will not store them. So, your foreach is just streaming through the result set from DbDataReader, and no one is storing them as you go gently down the stream.

Categories : C#

Taking a System.Type in and return an IEnumerable of this type
Why not to create a open generic type, which you can specify with an enum, like this: private static IEnumerable<T> GetAllEnumValues<T>() { if(typeof(T).IsEnum) return Enum.GetValues(typeof(T)).Cast<T>(); else return Enumerable.Empty<T>(); //or throw an exception } then having enum enum Questions { Good, Bad } this code foreach (var question in GetAllEnumValues<Questions>()) { Console.WriteLine (question); } will print: Good Bad

Categories : C#

Where to store image,in database or server folder
I will recommend to store the images in the folder structure, because it is easier to download and do some changes (image quality / optimize) and then put back to server. Without any interaction with database (for security reason about database structure or data) it is easy to do operations on image as per your / client needs. More flexibility if you run out of storage space (move them to another disk), even use them in other apps

Categories : Database

Proper Data Type in SQL Server to store Scientific Notation value? (Ex. 10^3)
If you want to use your data in numeric calculations, it is probably best to represent your data using once of SQL servers native numeric data type. Since you show scientific notation, it is likely you will want to use either REAL or FLOAT. Real is basically 7 decimal digits of precision and float has 15 digits of precision (at least this is how they are normally used). You can actually specify reduced precision for FLOAT, but in practice most people just use REAL in that case. REAL takes 4 bytes of storage, and FLOAT requires 8 bytes. The other numeric types are for fixed decimal point arithmetic.

Categories : SQL

store a blob string in database table
Refer to this link Writing BLOB values to a database. From MSDN: To write a BLOB value to your database, issue the appropriate INSERT or UPDATE statement and pass the BLOB value as an input parameter. If your BLOB is stored as text, such as a SQL Server text field, you can pass the BLOB as a string parameter. If the BLOB is stored in binary format, such as a SQL Server image field, you can pass an array of type byte as a binary parameter.

Categories : C#

How do I generically reference a local table in a SQL Server database from an assembly installed in that database?
All you have to do is use a context connection. At the moment it may not seem obvious, but CLR code always executes in some context. There is always something (somebody) that executed the code directly or in some parent scope (stored procedure calls CLR function, CLR trigger fires on insert etc). When program execution reaches context connection, it just takes connection parameters (server, database, SET options etc) of that scope. I want this method/storedproc to refer to a specific known table in the database. After context connection is opened, you are querying your database as usual. using (SqlConnection conn = new SqlConnection("context connection=true")) { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM MyTable"); SqlContext.Pipe.ExecuteAndSend(cmd); }

Categories : Sql Server

Extra table in database Entity Framework Code First With Database Migrations
We do this with no issues. We do add the table through the migration though so we we can ensure all developers have the same schema. If you want to skip this and go via SQL Management studio then you should have no issued either. Sql(@"CREATE TABLE.....")

Categories : C#

Better store images on server or image strings on database?
I think it is not a good idea to store image string in database instead of just its path (image name). Store your image on server and its name or path in database. Because retrieving image string from db and creating image for it each time you need that image is expensive. So better store its name only in server.

Categories : Mysql

Deploying code first code migrations based web app to server, but it's not creating the database
Well, one problem you have: you're defining both Integrated Security=True (i.e. Windows authentication) as well as User ID=...;Password=.... (i.e. SQL Server authentication) in your connection string. Choose one or the other - but not both at the same time! If you do have that user myUser specified as a login in your SQL Server, right now, it will not be used, because the Integrated Security=True setting will prevail ... So change your connection string to: <add name="Context" connectionString="Data Source=ServerDbInstance;Initial Catalog=blahblah;User ID=myUser;Password=myPassword" providerName="System.Data.SqlClient" /> and see if now, you're myUser user will be used.

Categories : Sql Server

postgresql-simple: get a list of table names in a database
as already answered in a comment above (due to lack of privileges): don't use postgresql-simple at all, but plain SQL on the internal postgresql tables: select schemaname, tablename from pg_tables; sorry for the noise.

Categories : Database

No errors or results when executing simple query on SQL Server database
The function getdate() actually returns a datetime. Try converting it to a date: AND SessionDate = cast(getdate() as date) The time component is probably the problem -- preventing a match between the date and the datetime.

Categories : C#

How to store database table schema (>50 columns) in Java
If all that you need is to create table or migrate database in general you might want to look at http://flywaydb.org/ or http://www.liquibase.org/ you will not repent

Categories : Java

Store a database table in memory in a C# website application?
If the table is small and frequently queried, there is an outstanding chance that the data and any indices is entirely in SQL Server's memory, the query plan is cached, and that the query will be extremely fast. Measure the actual performance impact before making any changes. If you see there is a performance impact, there are many caching strategies that you can use to reduce trips to the database. More information about access patterns to the table and the need for information consistency would be needed to recommend a specific caching strategy. You state to get the same information over and over again but also state once every 15 minutes If the information really is the same over and over, you can load it once into the ASP.Net cache at application start. If it might c

Categories : C#

Extract and store table values from database to dataValues
read Oracle tutorial How to use Tables reset DefaultTableModel to null, before a new Objects from JDBC are executed, added to DefaultTableModel, use (there are a few another methods, you can to starting with) model.setRowCount(0); create DefaultTableModel, JTable as local variables, re_use those variables, don't to create a new those Objects, then is required to remove uselles Objects and add a new Objects to Swing GUI override getColumnClass, its very important for JTables view to know data types stored in DefaultTableModel create (I assumed that there isn't another column structure, if yes then multiplay this variables) ColumnModel as local variable don't to reinvent the wheel, search for ResultSetTableModel, or better TableFromDatabase

Categories : Java

Exit code from qx// within Perl's Simple HTTP Server is always -1?
I tracked through HTTP::Server::Simple::CGI and it seems that it sets $SIG{'CHLD'}='IGNORE' as a precaution against zombie processes. Setting local $SIG{'CHLD'}='DEFAULT' immediately before my invocation of qx// allows me access to the return code.

Categories : Perl

Simple function to pull field data from a database table
please try with the following ,check your connection variables are correct. <?php function fetch_data(){ $user="root"; $pass=""; $dsn='mysql:dbname=mydata;host=localhost;'; try{ $db =new PDO($dsn,$user,$pass); } catch(PDOException $e){ echo "connection failed ".$e->getMessage(); } //replace the code block from $user to end of catch statement because that might be within //your included file connect.php $query=$db->prepare("SELECT Value FROM settings WHERE Name = ?"); $name="SiteSlogan";//or SiteTitle $query->bindParam(1,$name, PDO::PARAM_STR); $query->execute(); $query->bindColumn("Value",$value); $query->fetch(); echo $value; // or you can add more columns in bincolumn like //$query->bindColumn("id",$id); //echo $id; } fetch_data(); ?>

Categories : PHP

Designing table to store XML data in SQL Server 2008 R2
If the field is going to be used to store application payloads and the application can properly handle versioning or future modifications to the structure then I would go with an xml field. The only drawback to storing as xml is that queries can be more time consuming as opposed to flattened out data. If your apps handle all data being handed of as xml then this becomes a smaller hurdle to jump.

Categories : Sql Server

Store login information in one table in school database with conditional relation
Use Table Inheritance. Read up on The Party Model.

Categories : Database

Any obvious drawbacks for using a code versioning system to store history of changes to a database record
Instead of exporting data into JSON (via BSON, as that is what mongodump provides), I would suggest you create "archive" collections for each collection in MongoDB. You can then move outdated versions of your documents to this archive collection in the same format that you have them in your normal collection. As long as you store a date with the documents, you can very easily retrieve earlier versions without having to use a cumbersome solution such as a GIT/HG repository. Comparing versions is something you will probably need to visualize anyway, so doing that with JSON representations of documents instead of the real documents isn't a real benefit anyway.

Categories : GIT

Store data both in base and derived tables in Table-per-type inheritance in Entity Framework
In your DbContext's OnModelCreating override, use the following: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Base>().Map(m => { m.ToTable("Base"); }); modelBuilder.Entity<Derived>().Map(m => { m.MapInheritedProperties(); m.ToTable("Derived"); }); }

Categories : Entity Framework

Call store procedure from dapper which accept list of user defined table type
My problem is also that I have cars in generic list List Cars and I want pass this list to store procedure. It exist elegant way how to do it ? You need to convert your generic list Car to a datatable and then pass it to storedprocedure. A point to note is that the order of your fields must be same as defined in the user defined table type in database. Otherwise data will not save properly. And it must have same number of columns as well. I use this method to convert List to DataTable. You can call it like yourList.ToDataTable() public static DataTable ToDataTable<T>(this List<T> iList) { DataTable dataTable = new DataTable(); PropertyDescriptorCollection propertyDescriptorCollection = TypeDescriptor.GetProperties(typeof(T)); for

Categories : C#

what kind of 'select' in ms sql server store procedure will be returned to dataset in c# code?
The easiest way is to execute the stored procedure in the Management Studio and see what's returned. As a rule of thumb, the following (maybe incomplete) list of selects will not return anything to C#: IF EXISTS (SELECT ...) SELECT TOP 1 @variable = Field FROM ... SET @variable = (SELECT TOP 1 Field FROM ...) INSERT INTO ... SELECT ... ... WHERE Field IN (SELECT ...) ... WHERE Field = (SELECT TOP 1 ...) DECLARE ... CURSOR FOR SELECT ... One could say that every SELECT, the results of which are not consumed by a surrounding statement or the stored procedure itself is returned to the caller.

Categories : Sql Server

Unable to cast object of type 'System.Linq.OrderedEnumerable`2[***]' to type 'System.Collections.Generic.IEnumerable`1[***]'
You're trying to convert a collection of DirectoryToken to a collection of Token. This is called a covariant conversion, and it's only supported in .Net 4.0 or later. If you can't upgrade, you can call .Cast<Token>() to create a new IEnumerable<T> instance (actually an iterator) that casts each object to the desired type. Under no circumstances do you need an explicit cast operation.

Categories : C#

How to build a Sql Server table to store Quiz answers paired with the questionId?
Do not store denormalized data - this will make life a pain later on1. Okay, now that that's out of the way we can skip past the first approach .. :) The approach at the bottom looks "like a start", but there are several issues. Firstly, quizDate has no business being there (it is related to a quiz, not an answer) and, secondly, the schema doesn't capture who actually took the quiz. My model (shown as a simplified form as I capture criteria groupings, multiple deployments, dimensions, aspects and multi-values which are overkill for a simple case) looks similar to the following at heart: -- Survey/Quiz "has many Questions" Survey (SurveyStartedAt, SurveyExpiresAt) -- Question "belongs to a Survey" Question (FK Survey, QuestionPrompt, QuestionRules..) -- Each Participant can "respond to a

Categories : SQL

Passing a simple IEnumerable to view and using foreach to loop through returns a blank screen?
You never add the new customers to customers, you simple instantiate them. Try the following instead: public ActionResult Index() { List<Customer> customers = new List<Customer>(); customers.Add(new Customer { FullName = "MrA", Age = 25}); customers.Add(new Customer { FullName = "MrB", Age = 125 }); return View(customers); }

Categories : Asp Net Mvc

INT type with Max Size in SQL Server database
They are already defined by that type you use, for bigint that would be 8 bytes. See reference

Categories : C#

C# property of type IEnumerable
Start with the following implementation. Why? It provides minimum knowledge and possibilities to the caller. you can use the class with the default constructor => no thinking needed about what happens to the parameter Clauses is always initialized => no need to check for null Clauses is IEnumerable => minimum set of functionality, maximum flexibility for inner representation If you can live with the implementation, you are done. If you think that a ContainerQuery without Clause doesn`t make sense, add it to the constructor so that the caller is forced to give a value. If you suggest that the caller need some methods from ICollection (adding/removing after construction of ContainerQuery) than use this interface. And so on ... public class ContainerQuery : IContainerQuery { public

Categories : C#

IEnumerable property without type
You need to use the non-generic type System.Collections.IEnumerable. (note the different namespace) Note that in .Net 4.0+, you can use IEnumerable<object> instead (due to covariance).

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.