How I search DataGridView with text column?
-
I had mistake to define my SQL Server database table with all columns with TEXT, with my DataGridView the following codes are working fine (it will show every thing with its randome order):
cmd = New SqlCommand("SELECT \* FROM GuestInfoStore", con) If con.State = ConnectionState.Closed Then con.Open() myDA = New SqlDataAdapter(cmd) myDataSet = New DataSet() myDA.Fill(myDataSet, "MyTable") DataGridView\_INFO.DataSource = myDataSet.Tables("MyTable").DefaultView
In my table, there is a column FirstName, if I use:
cmd = New SqlCommand("SELECT * FROM GuestInfoStore ORDER BY FirstName", con)
I will have an error since SQL can't compare with Text column, but it is too late for me to change FirstName column back to char(50) or so ... can anyone help me on this? Thank in-advanced :doh:
-
I had mistake to define my SQL Server database table with all columns with TEXT, with my DataGridView the following codes are working fine (it will show every thing with its randome order):
cmd = New SqlCommand("SELECT \* FROM GuestInfoStore", con) If con.State = ConnectionState.Closed Then con.Open() myDA = New SqlDataAdapter(cmd) myDataSet = New DataSet() myDA.Fill(myDataSet, "MyTable") DataGridView\_INFO.DataSource = myDataSet.Tables("MyTable").DefaultView
In my table, there is a column FirstName, if I use:
cmd = New SqlCommand("SELECT * FROM GuestInfoStore ORDER BY FirstName", con)
I will have an error since SQL can't compare with Text column, but it is too late for me to change FirstName column back to char(50) or so ... can anyone help me on this? Thank in-advanced :doh:
Curious 2009 wrote:
it is too late for me to change FirstName column back to char(50)
it is never too late to fix a mistake. Things can only get worse if you don't. You could: - add a field with the correct type; - automatically copy the existing field to the new one; - gradually adapt your software, first the field producers (methods that write the field): make them write both fields; then the field consumers (the methods that read the field): make them read the new field. - when all is done, remove the redundant field. The alternative is a lot of ugly code, that will grow and grow over time, as you keep adding features. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
Curious 2009 wrote:
it is too late for me to change FirstName column back to char(50)
it is never too late to fix a mistake. Things can only get worse if you don't. You could: - add a field with the correct type; - automatically copy the existing field to the new one; - gradually adapt your software, first the field producers (methods that write the field): make them write both fields; then the field consumers (the methods that read the field): make them read the new field. - when all is done, remove the redundant field. The alternative is a lot of ugly code, that will grow and grow over time, as you keep adding features. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
You are right & I will do as you suggested! Thank :)
-
You are right & I will do as you suggested! Thank :)
Good. If it is a simple TEXT->VARCHAR change, I think you can tell SQL Server to do that in place, in a single step. I haven't so far, I have done similar things with MySQL. It is trickier when more complex formatting is involved, such as string->DateTime. It is always safe to make an extra field as a backup! :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
Good. If it is a simple TEXT->VARCHAR change, I think you can tell SQL Server to do that in place, in a single step. I haven't so far, I have done similar things with MySQL. It is trickier when more complex formatting is involved, such as string->DateTime. It is always safe to make an extra field as a backup! :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
I did copy & it works, I will try to find the command for simple TEXT->VARCHAR change Thank again
-
I did copy & it works, I will try to find the command for simple TEXT->VARCHAR change Thank again
There is a management tool SSMS, that should be able to do such operations interactively. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
Curious 2009 wrote:
it is too late for me to change FirstName column back to char(50)
it is never too late to fix a mistake. Things can only get worse if you don't. You could: - add a field with the correct type; - automatically copy the existing field to the new one; - gradually adapt your software, first the field producers (methods that write the field): make them write both fields; then the field consumers (the methods that read the field): make them read the new field. - when all is done, remove the redundant field. The alternative is a lot of ugly code, that will grow and grow over time, as you keep adding features. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
Following is the code sample used to display the outlook folder dialog using VB.NET [VB.NET CODE STARTS] Dim objOutlook As Object Dim objOlNamespace As Object Dim objOlFolder As Object objOutlook = CreateObject("Outlook.Application") ' create outlook application object at the run time objOlNamespace = objOutlook.GetNamespace("MAPI") objOlFolder = objContactsNS.PickFolder ' displays the folder dialog [VB.NET CODE ENDS] http://www.mindfiresolutions.com/Open-Outlook-folder-dialog-and-select-folder-using-VBNET-896.php[^]
Cheers, Eliza
-
Following is the code sample used to display the outlook folder dialog using VB.NET [VB.NET CODE STARTS] Dim objOutlook As Object Dim objOlNamespace As Object Dim objOlFolder As Object objOutlook = CreateObject("Outlook.Application") ' create outlook application object at the run time objOlNamespace = objOutlook.GetNamespace("MAPI") objOlFolder = objContactsNS.PickFolder ' displays the folder dialog [VB.NET CODE ENDS] http://www.mindfiresolutions.com/Open-Outlook-folder-dialog-and-select-folder-using-VBNET-896.php[^]
Cheers, Eliza
Garbage. Utter garbage. And it doesn't have anything to do with the original posters problem.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...