Article View: borland.public.csharpbuilder.language.csharp
Article #3Re: Reading MS Access Memo fields problem
From: Barry Kelly
Date: Wed, 19 Apr 2006 10:29
Date: Wed, 19 Apr 2006 10:29
40 lines
2368 bytes
2368 bytes
On Mon, 17 Apr 2006 18:00:24 +0430, "M. Noroozi Eghbali"
<galaxy@irandoc.ac.ir> wrote:
> Hi All,
>
> I used the below code to get the information from a MS Access database file:
> ----------------------------------------------------
> bdpConnection1.Open();
> bdpDataAdapter1.SelectCommand.CommandText = "SELECT * FROM Info WHERE
> Email = '" +
> email.Text + "'";
I'd strongly advise using parameterised queries instead (check out
[paramName] for JET SQL queries, IIRC). The approach you are using
here is a security risk. What if the user typed in <<' OR Email NOT
NULL AND Email <> '>> into your "email" text box?
> bdpDataAdapter1.FillSchema(dataSet1, SchemaType.Source, "Info");
> RowNum = bdpDataAdapter1.Fill(dataSet1);
> if(RowNum != 0)
> {
> UserInf.DownloadedFile =
> dataSet1.Tables["Info"].Rows[0]["DownloadedFile"].ToString();//***
> }
> bdpConnection1.Close();
> ------------------------------------------------------
>
> The "DownloadedFile" field of the database is of type Memo. After running
> the code, the value of the UserInf.DownloadedFile is "system.char[]" instead
> of the correct value of that. Any help?
System.Char[] can be converted into a System.String using the String
constructor. So:
---8<---
char[] downloadedFile = (char[])
dataSet1.Tables["Info"].Rows[0]["DownloadedFile"];
UserInf.DownloadedFile = new String(downloadedFile);
--->8---
-- Barry
Technical Details
Message-ID:
<kn3c421mrvlf8slgl1ss1ft390ih66nh95@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4443987c@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,4333d6d24eb37ebf X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: Barry Kelly <barry.j.kelly@gmail.com> Newsgroups: borland.public.csharpbuilder.language.csharp Subject: Re: Reading MS Access Memo fields problem Date: Wed, 19 Apr 2006 11:29:29 +0100 Message-ID: <kn3c421mrvlf8slgl1ss1ft390ih66nh95@4ax.com> References: <4443987c@newsgroups.borland.com> X-Newsreader: Forte Agent 3.3/32.846 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 83.141.85.30 X-Trace: newsgroups.borland.com 1145442577 83.141.85.30 (19 Apr 2006 03:29:37 -0700) Lines: 40 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail