Click here to Skip to main content
15,888,351 members
Home / Discussions / Database
   

Database

 
GeneralRe: Sql server: create table with column that support unique and multiple nulls Pin
w1424324-May-17 17:32
w1424324-May-17 17:32 
GeneralRe: Sql server: create table with column that support unique and multiple nulls Pin
Richard Deeming25-May-17 0:51
mveRichard Deeming25-May-17 0:51 
AnswerRe: Sql server: create table with column that support unique and multiple nulls Pin
ZurdoDev24-May-17 3:15
professionalZurdoDev24-May-17 3:15 
GeneralRe: Sql server: create table with column that support unique and multiple nulls Pin
Richard Deeming24-May-17 8:19
mveRichard Deeming24-May-17 8:19 
GeneralRe: Sql server: create table with column that support unique and multiple nulls Pin
ZurdoDev24-May-17 8:24
professionalZurdoDev24-May-17 8:24 
GeneralRe: Sql server: create table with column that support unique and multiple nulls Pin
w1424324-May-17 17:45
w1424324-May-17 17:45 
GeneralRe: Sql server: create table with column that support unique and multiple nulls Pin
ZurdoDev25-May-17 0:49
professionalZurdoDev25-May-17 0:49 
QuestionDisplay data only from search parameters Pin
rattlerrFx23-May-17 7:16
rattlerrFx23-May-17 7:16 
Hi, I have a small program that is for my own use that has a small database. In my program i have a DataGrid to display the information. Right now when i search i have to search via columns, what i want is to search for data contained in the column rows and only display the data searched. Below is the code i have that will return information when a "Column" is entered into the textbox "tbSearch" but I need to be able to search the column rows. I have nine columns that will contain data and i need to search those column rows.

C#
private void button_Click(object sender, RoutedEventArgs e)
        {
            
            using (SqlConnection conn = new SqlConnection())
            {
                int result = 0;
                string searchOut = tbSearch.Text;
                //using (SqlConnection con = new SqlConnection())
                conn.ConnectionString = " Data Source=(LocalDB)\\MSSQLLocalDB;Database=cloudyhamdb.mdf;Trusted_Connection=True;AttachDbFilename =|DataDirectory|cloudyhamdb.mdf; Integrated Security = True;";
                
                SqlCommand MyCommand = new SqlCommand("INSERT INTO clouddata " + " (First_Name, Last_Name, Grid_Square, Country, State, Call_Sign, Date_Time, Mode, Power)" + " Values (@First_Name, @Last_Name, @Grid_Square, @Country, @State, @Call_Sign, @Date_Time, @Mode, @Power)", conn);
                MyCommand.Parameters.Add("@First_Name", System.Data.SqlDbType.Text);
                MyCommand.Parameters.Add("@Last_Name", System.Data.SqlDbType.Text);
                MyCommand.Parameters.Add("@Grid_Square", System.Data.SqlDbType.Text);
                MyCommand.Parameters.Add("@Country", System.Data.SqlDbType.Text);
                MyCommand.Parameters.Add("@State", System.Data.SqlDbType.Text);
                MyCommand.Parameters.Add("@Call_Sign", System.Data.SqlDbType.Text);
                MyCommand.Parameters.Add("@Date_Time", System.Data.SqlDbType.SmallDateTime);
                MyCommand.Parameters.Add("@Power", System.Data.SqlDbType.Text);
                MyCommand.Parameters.Add("@Mode", System.Data.SqlDbType.Text);

                MyCommand.Parameters["@First_Name"].Value = Convert.ToString(tbFirstName.Text);
                MyCommand.Parameters["@Last_Name"].Value = Convert.ToString(tbLastName.Text);
                MyCommand.Parameters["@Grid_Square"].Value = Convert.ToString(tbGridSquare.Text);
                MyCommand.Parameters["@Country"].Value = Convert.ToString(tbCountry.Text);
                MyCommand.Parameters["@State"].Value = Convert.ToString(tbState.Text);
                MyCommand.Parameters["@Call_Sign"].Value = Convert.ToString(tbCallSign.Text);
                MyCommand.Parameters["@Date_Time"].Value = Convert.ToDateTime(DateTime.Now);
                MyCommand.Parameters["@Power"].Value = Convert.ToString(tbPower.Text);
                MyCommand.Parameters["@Mode"].Value = Convert.ToString(tbMode.Text);

                 conn.Open();
                MyCommand.ExecuteNonQuery();
                

                SqlDataAdapter da = new SqlDataAdapter();
                
                
                da = new SqlDataAdapter("Select * FROM clouddata", conn);
                DataSet ds = new DataSet();

                if (tbSearch.Text.Length >= 1)
                {
                    da.Fill(ds, "MyDataBinding");
                    DataRow[] returnRows = ds.Tables[0].Select("Last_Name" + searchOut);
                 
                    returnRows = ds.Tables[0].Select("First_Name=" + searchOut);
                    result = returnRows.Length;
                    dataGrid2.DataContext = ds.Tables[0];
                    int results = MyCommand.ExecuteNonQuery();

                }
                
                conn.Close();
            }

        }


modified 23-May-17 13:26pm.

QuestionRe: Display data only from search parameters Pin
CHill6023-May-17 10:52
mveCHill6023-May-17 10:52 
AnswerRe: Display data only from search parameters Pin
rattlerrFx23-May-17 13:21
rattlerrFx23-May-17 13:21 
GeneralRe: Display data only from search parameters Pin
CHill6024-May-17 1:06
mveCHill6024-May-17 1:06 
QuestionTeam Please help on the below request Pin
ganesh_naganna23-May-17 0:55
ganesh_naganna23-May-17 0:55 
AnswerRe: Team Please help on the below request Pin
Mycroft Holmes23-May-17 14:55
professionalMycroft Holmes23-May-17 14:55 
QuestionSQL for dynamic mappings Pin
Danpeking22-May-17 3:13
Danpeking22-May-17 3:13 
QuestionRe: SQL for dynamic mappings Pin
CHill6022-May-17 4:19
mveCHill6022-May-17 4:19 
AnswerRe: SQL for dynamic mappings Pin
Danpeking22-May-17 4:30
Danpeking22-May-17 4:30 
AnswerRe: SQL for dynamic mappings Pin
CHill6022-May-17 4:27
mveCHill6022-May-17 4:27 
GeneralRe: SQL for dynamic mappings Pin
Danpeking22-May-17 4:36
Danpeking22-May-17 4:36 
GeneralRe: SQL for dynamic mappings Pin
CHill6022-May-17 4:39
mveCHill6022-May-17 4:39 
GeneralRe: SQL for dynamic mappings Pin
Danpeking22-May-17 5:46
Danpeking22-May-17 5:46 
AnswerRe: SQL for dynamic mappings Pin
Danpeking24-May-17 23:28
Danpeking24-May-17 23:28 
GeneralMessage Closed Pin
18-May-17 20:29
Member 1321003518-May-17 20:29 
GeneralRe: oracle fusion procurement Pin
Richard MacCutchan18-May-17 21:49
mveRichard MacCutchan18-May-17 21:49 
GeneralRe: oracle fusion procurement Pin
CHill6018-May-17 22:24
mveCHill6018-May-17 22:24 
GeneralRe: oracle fusion procurement Pin
Richard MacCutchan18-May-17 22:35
mveRichard MacCutchan18-May-17 22:35 

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.