Posts tagged sql
assuming you have a datagridview that has data in it.
you want to avoid recalling sql from the database & just want to filter the datagrid.
you can do the following, What you need (1 datagridview (data), 1 button (search), 1 textbox (string to search), 1 variable to precise the criteria your searching for)
Dim findcrit as string Dim dt As DataTable = Ds_Pos.Employees Dim dv As New DataView(dt) Dim _RowFilter As String = "" Dim _FieldType = dt.Columns(findcrit).DataType.ToString Select Case _FieldType Case "System.Int32" _RowFilter = "convert(" & findcrit & ", 'System.String') like '" & Me.TextBox1.Text & "'" Case "System.Int64" _RowFilter = "convert(" & findcrit & ", 'System.String') like '" & Me.TextBox1.Text & "'" Case "System.Double" _RowFilter = "convert(" & findcrit & ", 'System.String') like '" & Me.TextBox1.Text & "'" Case "System.String" _RowFilter = findcrit & " like '" & TextBox1.Text & "*'" End Select dv.RowFilter = _RowFilter EmployeesDataGridView.DataSource = dv
The cases are to cast the type of variable from any type to string because you can only use the method on string data types.
the idea is to move the content to a data table then filter then return it back to the datatable.
If you’ve done a wordpress upgrade which included either copying another wp database or changing the current one’s table prefix (as well as changing the $table_prefix PHP variable in your config file,) you will most likely be met with this warning when you try to log in:
You do not have sufficient permissions to access this page.
The reason for this is that everything in wordpress that accesses info in the db does so from PHP using the $table_prefix variable, and when you first installed your blog, a couple of options are set in the database that include that value, which makes it not really so dynamic! 😉
After rooting through my db, I found 5 or 6 values that still had the old table prefix in – mostly in the `usermeta` table, but also one in the `options` table. To make sure I got them all, I ran these simple SQL statements in phpMyAdmin to update all the values:
_usermeta table and _options table
Well this is a great idea from Microsoft, but what if you want them all , or you want more then 200 rows like me , I am greedy , I like everything….
Any ways I was prepared to hack the registry for this one , but it seems you don’t really have to , and its in very simple to do and find…
Lesson 1 learned, late nights and SQL don’t mix.
Lesson 2 Change the Top 200 rows
Tools -> Options ->SQL Server Object Explorer, Expand this tree
And there you go change it to your desired amount, 0 = everything!
This is the youtube link for my demonstration :