Click here to Skip to main content
15,916,180 members
Home / Discussions / C#
   

C#

 
GeneralRe: trap state changes (standbye, hibernate, etc) Pin
vista2719-Jul-04 13:57
vista2719-Jul-04 13:57 
GeneralRe: trap state changes (standbye, hibernate, etc) Pin
Heath Stewart20-Jul-04 3:40
protectorHeath Stewart20-Jul-04 3:40 
GeneralCultureInfo for unsupported Culture Pin
Colin Angus Mackay19-Jul-04 11:25
Colin Angus Mackay19-Jul-04 11:25 
GeneralRe: CultureInfo for unsupported Culture Pin
Heath Stewart19-Jul-04 11:40
protectorHeath Stewart19-Jul-04 11:40 
GeneralRe: CultureInfo for unsupported Culture Pin
Colin Angus Mackay20-Jul-04 2:39
Colin Angus Mackay20-Jul-04 2:39 
GeneralRe: CultureInfo for unsupported Culture Pin
Heath Stewart20-Jul-04 3:56
protectorHeath Stewart20-Jul-04 3:56 
GeneralRe: CultureInfo for unsupported Culture Pin
Colin Angus Mackay20-Jul-04 10:45
Colin Angus Mackay20-Jul-04 10:45 
GeneralVery simple search on a form Pin
janigorse19-Jul-04 10:59
janigorse19-Jul-04 10:59 
Hello!
This is my first post. I have a little problem. I have build a small Windows Form application. It has 1 form and a couple of buttons and textboxes and a datagrid. I want to build a simple search. So, if I type a letter "D" in a textbox, I want in a DataGrid a list of all names that starts with a "D". If I type further a letter "a" and "v" for example, I would get a "Dave" names for example.
This is what I programmed so far:


static void FilterData()<br />
		{<br />
<br />
			try<br />
			{<br />
<br />
				string strFilter = "SELECT Avtosalon.Ime," + <br />
					"Naslov.Ulica, Naslov.PostnaSt, Naslov.Kraj, Avtosalon.Telefon," + <br />
					"Avtosalon.EPosta, Avtosalon.Vodja, Avtosalon.OdpiralniCas " +<br />
					"FROM Avtosalon INNER JOIN Naslov ON Avtosalon.IDNaslov = Naslov.IDNaslov ";<br />
<br />
				// Ime<br />
				if (!MyForm.txtIme.Focused)<br />
				{<br />
					strFilter = strFilter + "WHERE Avtosalon.Ime LIKE '" + MyForm.txtIme.Text + "%'";<br />
					if (MyForm.txtUlica.Focused)<br />
						strFilter = strFilter + " AND Naslov.Ulica LIKE '" + MyForm.txtUlica.Text + "%'";<br />
					else if (MyForm.txtPostnaSt.Focused)<br />
						strFilter = strFilter + " AND Naslov.PostnaSt LIKE '" + MyForm.txtPostnaSt.Text + "%'";<br />
					else if (MyForm.txtKraj.Focused)<br />
						strFilter = strFilter + " AND Naslov.Kraj LIKE '" + MyForm.txtKraj.Text + "%'";<br />
					else if (MyForm.txtTelefon.Focused)<br />
						strFilter = strFilter + " AND Avtosalon.Telefon LIKE '" + MyForm.txtTelefon.Text + "%'";<br />
					else if (MyForm.txtEPosta.Focused)<br />
						strFilter = strFilter + " AND Avtosalon.EPosta LIKE '" + MyForm.txtEPosta.Text + "%'";<br />
					else if (MyForm.txtVodja.Focused)<br />
						strFilter = strFilter + " AND Avtosalon.Vodja LIKE '" + MyForm.txtVodja.Text + "%'";<br />
					else if (MyForm.txtOdpiralniCas.Focused)<br />
						strFilter = strFilter + " AND Avtosalon.OdpiralniCas LIKE '" + MyForm.txtOdpiralniCas.Text + "%'";<br />
				}	<br />
<br />
				MyDataSet = new DataSet();<br />
				MyDataAdapter = new SqlDataAdapter(strFilter,conn); <br />
				MyDataAdapter.Fill(MyDataSet,"Avtosalon"); <br />
				MyDataAdapter.Dispose();<br />
				MyForm.BeginInvoke(CallDataBindToDataGrid);<br />
				strFilter = null;<br />
			}<br />
			catch (Exception ex)<br />
			{<br />
				MessageBox.Show(ex.Message.ToString());<br />
			}<br />
			<br />
		}<br />
<br />



<br />
<br />
		static void DataBindToDataGrid()<br />
		{<br />
			<br />
			// bind data to datagrid <br />
			MyForm.gridAvtosalon.DataMember = "Avtosalon"; <br />
			MyForm.gridAvtosalon.DataSource = MyDataSet;<br />
			MyDataSet = null;<br />
			MyDataAdapter = null;<br />
		}


private void txtIme_TextChanged(object sender, System.EventArgs e)<br />
		{<br />
			try<br />
			{<br />
				UpdateThread = new Thread(UpdateThreadStart);<br />
				UpdateThread.Name = "Update Thread";<br />
				UpdateThread.IsBackground = true;<br />
				UpdateThread.Start();<br />
				 <br />
				<br />
			}<br />
			catch (Exception ex)<br />
			{<br />
				MessageBox.Show(ex.Message.ToString());<br />
			}<br />
			<br />
		}



So, the problem is, when I type in a textbox, I get an error message "There is an open DataReader associated with this
Connection wich must be closed first" and I don't use DataReader at all. Could you help me, couse I study this now for
days and I can't see where is a problem. Thank in advance.
GeneralRe: Very simple search on a form Pin
Heath Stewart19-Jul-04 11:23
protectorHeath Stewart19-Jul-04 11:23 
Generalintegrate context menu with shell Pin
goooooooogle19-Jul-04 9:52
goooooooogle19-Jul-04 9:52 
GeneralRe: integrate context menu with shell Pin
Nick Parker19-Jul-04 10:40
protectorNick Parker19-Jul-04 10:40 
GeneralRe: integrate context menu with shell Pin
Dave Kreskowiak19-Jul-04 15:24
mveDave Kreskowiak19-Jul-04 15:24 
GeneralRichTextBox Question Pin
bneacetp19-Jul-04 9:44
bneacetp19-Jul-04 9:44 
GeneralRe: RichTextBox Question Pin
leppie19-Jul-04 11:12
leppie19-Jul-04 11:12 
GeneralRe: RichTextBox Question Pin
Heath Stewart19-Jul-04 11:31
protectorHeath Stewart19-Jul-04 11:31 
GeneralRe: RichTextBox Question Pin
bneacetp19-Jul-04 11:40
bneacetp19-Jul-04 11:40 
GeneralPrint button with SSRS Pin
clydeJones19-Jul-04 8:51
clydeJones19-Jul-04 8:51 
GeneralDynamic Help Using HtmlHelp API and COM Interfaces Pin
JimmyG1319-Jul-04 7:57
JimmyG1319-Jul-04 7:57 
GeneralKeyDown event is not firing while draging node on treeview Pin
god4k19-Jul-04 6:51
god4k19-Jul-04 6:51 
GeneralRe: KeyDown event is not firing while draging node on treeview Pin
leppie19-Jul-04 6:59
leppie19-Jul-04 6:59 
GeneralRe: KeyDown event is not firing while draging node on treeview Pin
Heath Stewart19-Jul-04 9:10
protectorHeath Stewart19-Jul-04 9:10 
GeneralReturning a filtered DataTable Pin
Andy H19-Jul-04 6:44
Andy H19-Jul-04 6:44 
GeneralRe: Returning a filtered DataTable Pin
Werdna19-Jul-04 8:58
Werdna19-Jul-04 8:58 
GeneralRe: Returning a filtered DataTable Pin
Heath Stewart19-Jul-04 9:04
protectorHeath Stewart19-Jul-04 9:04 
GeneralRe: Returning a filtered DataTable Pin
Andy H19-Jul-04 22:40
Andy H19-Jul-04 22:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.