Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Excel data to dataset

Excel data to dataset

Scheduled Pinned Locked Moved C#
databasesql-serversysadminhelptutorial
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sunil Wise
    wrote on last edited by
    #1

    Hi everyone, i am developing one application in that i need to get data from excel sheet to the dataset after that i'll have some calculations to do. In the excel sheet i have one column [dateregistered] the date format in that column is (mm/dd/yyyy hh:mm) i want the date format to be (mm/dd/yyy) from sql query. i have written a query below which is giving me error

    Syntax error (missing operator) in query expression 'CONVERT(varchar ,[dateregistered],103) Dates'.

    here i am getting the data directly from excel sheet not from sql server so i want know how to use convert function for retriving data from excel sheet string sql = "select CONVERT(varchar ,[dateregistered],103) Dates,[user],[client facility],sum([payroll score])LC from [sheet1$] group by [user],[client facility], CONVERT(varchar ,[dateregistered],103) order by [docQscribe user]"; da = new OleDbDataAdapter(sql, con); ds = new DataSet(); da.Fill(ds,"Table1");

    S 1 Reply Last reply
    0
    • S Sunil Wise

      Hi everyone, i am developing one application in that i need to get data from excel sheet to the dataset after that i'll have some calculations to do. In the excel sheet i have one column [dateregistered] the date format in that column is (mm/dd/yyyy hh:mm) i want the date format to be (mm/dd/yyy) from sql query. i have written a query below which is giving me error

      Syntax error (missing operator) in query expression 'CONVERT(varchar ,[dateregistered],103) Dates'.

      here i am getting the data directly from excel sheet not from sql server so i want know how to use convert function for retriving data from excel sheet string sql = "select CONVERT(varchar ,[dateregistered],103) Dates,[user],[client facility],sum([payroll score])LC from [sheet1$] group by [user],[client facility], CONVERT(varchar ,[dateregistered],103) order by [docQscribe user]"; da = new OleDbDataAdapter(sql, con); ds = new DataSet(); da.Fill(ds,"Table1");

      S Offline
      S Offline
      Sunil Wise
      wrote on last edited by
      #2

      sunilwise wrote:

      string sql = "select CONVERT(varchar ,[dateregistered],103) Dates,[user],[client facility],sum([payroll score])LC from [sheet1$] group by [user],[client facility], CONVERT(varchar ,[dateregistered],103) order by [user]";

      no probs i got the solution i modified my query to string sql = "select format([dateregistered],'MM/dd/yyyy') as Dates,[user],[client facility],sum([payroll score]) as LC from [sheet1$] group by [user],[client facility], format([dateregistered],'MM/dd/yyyy') order by [user]"; its working gr8 for me

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups