Click here to Skip to main content
13,090,418 members (46,053 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 3:56am
Updated 22-Feb-13 3: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 |
Web04 | 2.8.170813.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2017
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