Skip to content

Database

Discussions on database access, SQL, and ADO

This category can be followed from the open social web via the handle database@forum.codeproject.com

17.1k Topics 61.8k Posts
  • 0 Votes
    2 Posts
    0 Views
    M
    You can get an empty datatable from SQL with Select * from Tablename where 1-1. This will give you the SQL data type, they may differ from the Excel data type. An update statement will look like Update TableName set field1 = ValueFromExcelCell, field2 = ... where PrimareyKeyField = PrimaryKeyValueFromExcel The update needs to be execute for each row in the ExcelTable where the data has changed Never underestimate the power of human stupidity RAH
  • Entity Framework Book.

    learning help question announcement
    4
    0 Votes
    4 Posts
    0 Views
    M
    Sorry I can't read the title of the EF book having staked it out on the office floor drowned it in oil, put a stake through it and burnt it. Blasted thing just won't die! Never underestimate the power of human stupidity RAH
  • SQL Linq, Joins, returns 1st record over and over

    database csharp linq sales regex
    2
    0 Votes
    2 Posts
    0 Views
    J
    I had multiple billing and shipping addresses, in the join. So I need to redesign that feature.
  • Trouble working with dates again and union and sum

    sql-server
    9
    0 Votes
    9 Posts
    0 Views
    J
    I've seen those, never bothered to click on them. Thanks Guess you need to delete the message to keep it secret secret!
  • Database management

    question lounge database sysadmin discussion
    2
    0 Votes
    2 Posts
    0 Views
    Z
    Where did your question go? :confused: There are only 10 types of people in the world, those who understand binary and those who don't.
  • SQL Linq, select from select and join

    database csharp sql-server linq help
    5
    0 Votes
    5 Posts
    0 Views
    J
    I just made 1 context file with everything in it. Finally got the DateRanges working, was banging my head against the wall to figure it out. I had to wrap the Where statement in (), in VB its different to compare. Where (oh.OrderDate >= startDate And oh.OrderDate <= stopDate) Hey thanks for your help!, that was hard to figure out.
  • large database

    database postgresql com tools help
    12
    0 Votes
    12 Posts
    0 Views
    J
    3.5 billion records aren't anything strange. It's the amount that changes that's the problem. And since you also don't have any problems selecting the data, we have to look at the other side of the problem. Firstly we have to see the fact that Insert time is close to linear[^] with the number of indexes. So keeping that number low is important. But it's also very unlinearly depending on some other factors. So I have some questions: Do you have any unused surrogate keys? Are you inserting data in parallell or from more than one process at a time? Are you inserting data at one end of the index only? (Using ID, sequence or date for example) Are you just inserting, or are you updating and deleting at the same time aswell? Wrong is evil and must be defeated. - Jeff Ello
  • Database management

    database question lounge sysadmin discussion
    5
    0 Votes
    5 Posts
    0 Views
    W
    As already answered the man criteria would be; Is there a relation between the data? If there is, a single database is the most logical choice. However, there is also other things to consider such as maintenance, backups and so on. So even if the data isn't related, from the maintenance point of view it could simplify the situation if all the data is in one place. Of course if the amount of data grows huge over time you may have to separate it but in the beginning it would make sense to start small.
  • Save value of PREPARE into a variable

    question announcement sharepoint database com
    5
    0 Votes
    5 Posts
    0 Views
    W
    As the error says, the return value from your procedure to variable @param_eligible_days is null. Because of this null is being updated to the table and this is prohibited because the column is not null. So check why sp_populate_leave_summary returns NULL for the second parameter.
  • SQL Linq, updating multiple records

    csharp database linq tutorial question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Some help with SQL to Linq Conversions

    linq csharp database help
    5
    0 Votes
    5 Posts
    0 Views
    Richard DeemingR
    jkirkerx wrote: LINQ to Entities does not recognize the method 'System.DateTime AddDays(Double)' method, and this method cannot be translated into a store expression. You might need to move the date outside of the filter: Dim minDate As Date = Date.Today.AddDays(-30) messages = messages.Where(Function(m) m.ContactDate >= minDate) Alternatively, use the EntityFramework.SqlServer assembly, and the System.Data.Entity.SqlServer.SqlFunctions class[^]: messages = messages.Where(Function(m) m.ContactDate >= SqlFunctions.DateAdd("day", -30, SqlFunctions.GetDate())) "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • SQL Linq, query and then take result to query again

    database linq csharp
    2
    0 Votes
    2 Posts
    0 Views
    J
    Public Shared Function load_movieContributor_array( _ ByVal pMovieID As Integer, ByVal pPageIndex As Integer, ByVal pPageSize As Integer, ByRef pResults As IEnumerable(Of MovieIndex)) As Integer Dim pValue As Integer = 0 Dim context As New MoviesContext() Dim cResults = \_ (From m In context.Movies Where m.MovieID = pMovieID Select m.MovieContributor).SingleOrDefault() Dim m\_contributor As String = cResults Dim movies As IQueryable(Of Movies) = context.Movies movies = movies.Where(Function(m) m.MovieContributor = m\_contributor) movies = movies.OrderBy(Function(m) m.MovieName) 'Get a Single Page of Data If (pPageIndex = 0) Then movies = movies.Take(pPageSize + 1) Else movies = movies.Skip((pPageIndex + 1) \* pPageSize).Take(pPageSize) End If
  • SELECT then INSERT data in a matrix way

    database help question
    3
    0 Votes
    3 Posts
    0 Views
    F
    thank u it helped me a lot! :)
  • SQL Linq, concepts of writing queries

    database csharp linq tutorial
    3
    0 Votes
    3 Posts
    0 Views
    J
    That's Radical Man! It works like a charm. I figured out that Movies was my Model, and imported the Namespace for it. So I did some tweaks to get the record selection right, records displayed. I'm still stuck on using the context, instead of Dimensioning it, but the base of what I project into gets disposed before I can generate the HTML. So that's another subject. This SQL Linq is quite interesting, and seems to offer everything hand typed queries offer. It's fast. I'm stoked on my Data Access Layer DLL, Seems to be working. I know the model works now. If I can convert my asp.net webforms app program over to this, and be able to automatically create a database, and seed it with default values, and then if I change the database in one spot, and I can propagate the changes throughout the program, then I'm done. All I have to do is adopt the BootStrap CSS Concept used in MVC, and I can sell this thing finally. Thanks for taking the time to school me on this. I owe you the price of tuition for it. - Street Outlaws And Here's what I got. Public Shared Function load_index_array( _ ByVal pType As MovieType, ByVal pSortOrder As SortOrder, ByVal pPageIndex As Integer, ByVal pPageSize As Integer, ByRef pResults As IEnumerable(Of MovieItem)) As Integer Dim pValue As Integer = 0 Dim context As New MoviesContext() Dim movies As IQueryable(Of Movies) = context.Movies 'Sort Order Select Case pSortOrder Case SortOrder.Name movies = movies.OrderBy(Function(m) m.MovieName) Case SortOrder.Type movies = movies.OrderBy(Function(m) m.MovieType) Case SortOrder.Time movies = movies.OrderBy(Function(m) m.MovieTime) Case SortOrder.Lastest movies = movies.OrderByDescending(Function(m) m.MoviePostDate) Case SortOrder.Early movies = movies.OrderBy(Function(m) m.MoviePostDate) End Select 'Filter By Type Select Case pType Case MovieType.FLV movies = movies.Where(Function(m) m.flv) Case MovieType.H264 movies = movies.Where(Function(m) m.h264) End Select 'Get a Single Page of Data If (pPageIndex = 1) Then movies = movies.Take(pPageSize) Else movies = movies.Skip((pPageIndex - 1) \* pPageSize).Take(pPageSize) End I
  • Oracle Query Builder

    database csharp sql-server oracle wpf
    3
    0 Votes
    3 Posts
    0 Views
    J
    Do you need a graphical tool or just a text tool? Wrong is evil and must be defeated. - Jeff Ello
  • ssrs rendering format ppt pptx

    database sql-server com
    2
    0 Votes
    2 Posts
    0 Views
    L
    Please do not crosspost.
  • 0 Votes
    2 Posts
    0 Views
    A
    Behold, the power of a cup of coffee :rolleyes: Step 1: Raiserror in the SP with a severity of 11 or higher. 10 and lower ist considered a warning and won't throw an exception in vb.net. IF @intConflictingRows = 0 BEGIN INSERT INTO [dbo].[tbl] (Fields) VALUES (@Values); SELECT Fields FROM tbl WHERE (ID = SCOPE\_IDENTITY()) END ELSE BEGIN RAISERROR('Error: New interval overlapping existing data!', 11, 1) --do not return a return code here! END Step 2: Wrap the TableAdapterManager.UpdateAll in a Try-Catch-block, and catch all exception with a Messagebox. Try If Me.Validate() Then MyBindingsource.EndEdit() TableAdapterManager.UpdateAll(myDataset) Return True End If Return False Catch ex As Exception MessageBox.Show(ex.Message, "Error while saving!") Return False End Try
  • Take a look at my unbiased review on Spartagen Someone

    com architecture
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Take a look at my unbiased review on Spartagen Someone

    com architecture
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Entity Framework 6.0.3 problem

    database csharp sql-server visual-studio winforms
    2
    0 Votes
    2 Posts
    0 Views
    M
    SOLVED! The problem was caused by WHERE my APP-A project was located. At my work we have shared user folders that are hosted on the network, and that is where my APP-A project was located. The problem with that is that these shared folders are not trusted by our SQL servers, so when my application ran from that location the SQL server would reject the connection. I just moved my project to my local C: drive, rebuilt it and ran it and viola! it connects to the SQL server database without issue. My APP-B project was created on my local C: drive which is why it was able to access both the local SQLEXPRESS and the SQL server databases without issue. Sincerely, -Mark mamiller@rhsnet.org