Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4598492
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:24:25+00:00 2026-05-21T23:24:25+00:00

I have the following code: var wqry:TAdoQuery; … FillChar(wSpaces,cSpacesAfter,’ ‘); try wqry := TADOQuery.Create(nil);//here

  • 0

I have the following code:

var wqry:TAdoQuery;
...
  FillChar(wSpaces,cSpacesAfter,' ');
  try
    wqry := TADOQuery.Create(nil);//here the error
    wqry.Connection:=...

cSpacesAfter is a constant and has the value 1035. wSpaces is a local string variable. The problem is that I receive the following error when TAdoQuery is created

enter image description here

even it is in french, I believe you got the idea…..

If I comment the FillChar code, everything works ok. I have the usual compiler directives, nothing special. I’m using Delphi 7.

Can someone tell me what is wrong with that code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:24:26+00:00Added an answer on May 21, 2026 at 11:24 pm

    The troublesome code is most likely this one

    FillChar(wSpaces,cSpacesAfter,' ');
    

    I’m assuming that wSpaces is of string type. A string variable is in fact nothing more than a pointer to the data structure that holds the string. You don’t need to use pointer syntax because the compiler takes care of that for you.

    So what this code does is overwrite the variable holding that pointer with 4 space characters and then write 1031 more spaces over the top of whatever follows the variable. In short you will completely corrupt your memory. That would explain why the FillChar works but the very next line of code dies a painful and dramatic death.

    If your string indeed had space for 1035 characters your could instead write:

    FillChar(wSpaces[1], cSpacesAfter, ' ');
    

    However, if may be more idiomatic to write:

    wSpaces := StringOfChar(' ', cSpacesAfter);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: var sl: THashedStringList; begin sl:= THashedStringList.Create; sl.Duplicates := dupIgnore;
I have following code: var listDirectoryFtpRequest = (FtpWebRequest) WebRequest.Create(directoryUri); listDirectoryFtpRequest.Method = WebRequestMethods.Ftp.ListDirectory; listDirectoryFtpRequest.Credentials =
I have the following code: var submitHandler = function ($link, $form, close) { var
I have the following code: var refreshId = setInterval(function() { $(#footad).html('myjshere'); }, 15500); Where
I have the following code: var carsContext = new CarsDataContext(); IQueryable<Car> allCars = carsContext.Cars;
I have the following code var dbvalue = Ned; var deleteLink = '<a href=#delete
I have the following code: var bool:String = true; Without an if block or
I have the following code: var GoalPanelView = Backbone.View.extend({ // Bind to the goal
I have the following code: var tlp = new TableLayoutPanel { Location = new
I am using ASP.NET 3.5 with iTextSharp and I have the following code: var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.