For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
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.
privatevoid 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["@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);
SqlDataAdapter da = new SqlDataAdapter();
da = new SqlDataAdapter("Select * FROM clouddata", conn);
DataSet ds = new DataSet();
if (tbSearch.Text.Length >= 1)
DataRow returnRows = ds.Tables.Select("Last_Name" + searchOut);
returnRows = ds.Tables.Select("First_Name=" + searchOut);
result = returnRows.Length;
dataGrid2.DataContext = ds.Tables;
int results = MyCommand.ExecuteNonQuery();
Hi, I have a problem generating SQL to return a single row for a client. My table structure is the following...
Clients - ClientID, ClientName
Statuses - StatusID, StatusDescription, ClientID
StatusMappings - StatusID, ClientID
The statuses can be different depending on the client, so for example, clients table:
I'm not sure about the example you are presenting ... Are the following statements true?
- The Statuses table shows the possible statuses for each Client?
- The StatusMapping table shows the actual statuses for each client.
If that is the case then with the data you presented you cannot possibly get the results because for Client "Halifax" Status 'Draft Letter' is Id 3 and there is nothing on the StatusMappings table for that Id. Similarly 'Awaiting Response' would be Id 4.
Assuming you get the data sorted out then something like the following will work
SELECT * FROM
SELECT C.ClientID, ClientName, StatusDescription,
CASEWHEN SM.StatusID ISNOTNULLTHEN'Y'ELSE'N'ENDAS Actual
LEFTOUTERJOIN@Statuses S ON C.ClientID = S.ClientID
LEFTOUTERJOIN@StatusMappings SM on SM.StatusID = S.StatusID
MAX(Actual) FOR StatusDescription in ([Draft Letter],[Awaiting Response],[Complete])
WHERE ClientName = 'Barclays'
If you want to use it in an SSRS report then put the query into a Stored Procedure, passing the Client name or id as a parameter.
If the Status Descriptions are not standard or consistent (i.e. not the ones listed) then you will have to use some dynamic sql.
There are articles here on CodeProject on all the topics above