Click here to Skip to main content
11,932,103 members (66,195 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# C#4.0
Hello!! I want to search data/text like google in windows form. I have saves some text in MS-Access database and i want to search those data/texts in textBox of windows form. I have enabled "AutoCompleteMode=Suggest","AutoCompleteCustomSource=CustomSource" of the textBox. But sometimes it shows me an error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Please solve my problem. Thanks........
                AutoCompleteStringCollection acs = new AutoCompleteStringCollection();
                OleDbCommand cm = new OleDbCommand("select itemname from purchaseitem", cn);
                OleDbDataAdapter da = new OleDbDataAdapter(cm);
                OleDbDataReader dr = cm.ExecuteReader();
                if (dr.HasRows == true)
                    while (dr.Read())
                txt_itemname.AutoCompleteCustomSource = acs;
            catch (Exception ex)
                throw ex;
Posted 22-Feb-13 4:56am
Edited 22-Feb-13 4:59am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

StringBuilder sb = new StringBuilder();

// used on each read operation
byte[] buf = new byte[8192];
string GS = "";
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(GS);

// execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

// we will read data via the response stream
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
// fill the buffer with data
count = resStream.Read(buf, 0, buf.Length);
// make sure we read some data
if (count != 0)
// translate from bytes to ASCII text
tempString = Encoding.ASCII.GetString(buf, 0, count);

// continue building the string
while (count > 0);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100