16,018,353 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by ravitv (Top 29 by date)
ravitv
23-Aug-22 9:14am
View
Sorry OriginalGriff.....
I did a big mistake in Student Table Data, this gave the incorrect count or rows even when I add the line for checking 'Discontinued' Status....
Here is the code that works
CASE(@Status)
WHEN 1 THEN 'PASS'
WHEN 2 THEN 'FAIL'
ELSE 'DISCONTINUED'
END AS Status FROM StudentMst
WHERE ((@SID IS NULL)OR SID = @SID).... bla bla bla
Sorry for the troulble and thanks for suggesting to "read" CASE WHEN again,
as well as thanks again for spending your precious time to help me out of the problem.
Thanks
Ravi.
ravitv
23-Aug-22 7:38am
View
Sorry OriginalGriff, I dont have one,
All I have is this one
SELECT SId,SName,Std,Status,
CASE
WHEN (
((Status = '1')
)
THEN 'PASS'
ELSE 'FAIL'
END AS Status FROM StudentMst
WHERE ((@SID IS NULL)OR SID = @SID).... bla bla bla
I dont know how to do the changes to validate "Discontinued" status, WHEN Status=3 in the above SQL.
Kindly help,
Thanks
Ravi
ravitv
21-Aug-22 4:18am
View
Hi OriginalGriff,
here is another situation to include "Discontinued" when status=3.
How can I write the SQL please.
Thanks
Ravi
ravitv
21-Aug-22 3:59am
View
Oh...I figured it out OriginalGriff, thanks..
I forgot to include all the column names.
Excellent OriginalGriff,
thanks again.
Ravi
ravitv
21-Aug-22 3:39am
View
Thanks OriginalGriff,
but where can I use this
CASE WHEN Std = @GradeYouWantToMatch.........
in the Stored Procedure. I have no idea.
Can you please give me a clue
ravitv
13-Jun-22 12:14pm
View
Yes OriginalGriff - Thanks for the clue.
I tried this code and works well,
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"Data Source=.\....bla....bla....bla...");
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT States, COUNT(States) AS Total_Schools FROM tbl_PublicSchoolUSA GROUP BY States HAVING (COUNT(States) >= 1)",conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
foreach (DataRow row in dt.Rows)
{
TextBox3.Text = dt.Rows[0][0].ToString();
TextBox4.Text = dt.Rows[1][0].ToString();
TextBox5.Text = dt.Rows[2][0].ToString();
TextBox6.Text = dt.Rows[3][0].ToString();
}
}
but I want the count value to be displayed in "dynamically generated TextBox"
for the States that has some rows and SHOULD NOT display the TextBox that DOESNT have any rows.
(i.e) I want to display values in the TextBox for California,New York,Ohio,Illinois only.(other states are still under data entry)
So if I get any records entered in "tbl_PublicSchoolUSA" in "States" Column for Florida,Idaho then the values for Florida,Idaho
should be displayed along with other 4 States and so and so forth...
How can I achieve this.
Please help.
Thanks
Ravi.
ravitv
19-Oct-21 3:42am
View
Yes Member 15329613, but Unipam has given a link below that solves it.
Thanks
Ravi
ravitv
19-Oct-21 3:38am
View
Exactly Yes Unipam, Thank you so much, but sorry for late reply.
It solves my problem.
Thanks again.
Ravi
ravitv
9-Sep-21 8:38am
View
Sorry Richard, I dont understand,
My dummy image is in "~img/noimage.png" folder.
How can I use this?
Will sda.SelectCommand.Parameters.AddWithValue("@DefaultImage", "~img/noimage.png");
work with
...
.....
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
Sorry for troubling you.
ravitv
24-Aug-21 23:44pm
View
Sorry, please replace txtAge to txtAgeNew
ravitv
23-Aug-21 3:11am
View
I tried this Richard
txtAgeNew.Attributes.Add("readonly", "readonly");
in the form load event
and it works.
Thanks again Richard.
ravitv
23-Aug-21 3:10am
View
Thanks Wendelius,
I came across a forum that suggested to write a code in form load event as below
protected void Page_Load(object sender, EventArgs e)
{
txtAgeNew.Attributes.Add("readonly", "readonly");
....
......
.......
with design .aspx as
<asp:textbox id="txtAge" runat="server" visible="true" readonly="true">
and it works....!!!!!!!
The conversion nvarchar to int etc...nothing happened.
Anyway thanks Wendelius
ravitv
18-Aug-21 3:05am
View
I agree with you OriginalGriff, I made a mistake, I should follow your solution from my next project.
Thanks
Ravi
ravitv
16-Aug-21 3:42am
View
Hi Peter Leow,
Can you please update on your Solution1 code, I dont know how to implement your code.
It keeps adding more and more textboxes and checkboxes.
txtPassword.next().remove();
ravitv
10-Aug-21 5:10am
View
Wow great Richard, It works,
Thank you so much.
Ravi.
ravitv
1-Jul-21 10:23am
View
Thanks Richard, I will try this.
ravitv
1-Jul-21 9:40am
View
Hi Richard,
Thanks for quick reply and excellent solution, sorry for late reply.
But, how can use your code in a button click event if I already have c# code structure as below and display it in gridview?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Collections;
using System.Data.SqlClient;
...
.....
......etc.,
public partial class Search_Student: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
some login validation goes here
}
}
protected void btnSearchStudent_Click(object sender, EventArgs e)
{
HERE I need to your code to be executed
}
}
Thanks
Ravi
ravitv
24-Jun-21 4:32am
View
Sorry for the delayed reply, I am using itextsharp-5.5.13.2
The link you have given is an "ocean", All I need is to display "system date" in dd/mmm/yyyy and Page number/Total number of pages. at the bottom ot the pdf pages.
The code you have given works excellent but displays the date somewhat halfway - middle of the page.
Kindly help,
Thanks
Ravi
ravitv
23-Jun-21 8:10am
View
Your code works great, but, how to format that date to dd/mmm/yyyy hh:mm:ss am/pm
and put it in the bottom of the pdf page just below the coordinates say...
DrawLine(writer, 25f, document.Top - 750f, document.PageSize.Width - 25f, document.Top - 750f, BaseColor.RED);
ravitv
17-May-21 5:45am
View
Okay friends, now here is what i tried,
.........
....
...
...
The .aspx design part
Search For Search For <asp:dropdownlist id="drpgender" runat="server" cssclass="input">
<asp:listitem value="Girls">Girls
<asp:listitem value="Boys">Boys
Age Age From : <asp:dropdownlist id="drpagefrom" runat="server" width="53px" cssclass="input">
<asp:listitem>10
<asp:listitem>11
<asp:listitem>12
<asp:listitem>13
<asp:listitem>14
<asp:listitem>15
<asp:listitem>16
<asp:listitem>17
<asp:listitem>18
<asp:listitem>19
To :<asp:dropdownlist id="drpageto" runat="server" width="53px" cssclass="input">
<asp:listitem>10
<asp:listitem>11
<asp:listitem>12
<asp:listitem>13
<asp:listitem>14
<asp:listitem>15
<asp:listitem>16
<asp:listitem>17
<asp:listitem>18
<asp:listitem>19
And my code Behind .cs is
...
..
..
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
string WHERE;
protected void btnsearch_Click(object sender, EventArgs e)
{
string constr = (@"Data Source=Admin....................mdf;Integrated Security=True;User Instance=True");
using (SqlConnection con = new SqlConnection(constr))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
StringBuilder sbCommand = new StringBuilder("Select * from StudentRecord Where 1=1");
{
if (drpgender.SelectedItem.Value != "")
{
sbCommand.Append(" AND Gender=@Gender");
SqlParameter param = new SqlParameter("@Gender", drpgender.SelectedItem.Value);
cmd.Parameters.Add(param);
}
if (drpagefrom.SelectedItem.Text != "" && drpageto.SelectedItem.Text != "")
{
/* Need help in this line to search between selected Age from .aspx page dropdowncombobox value/text*/
}
cmd.CommandText = sbCommand.ToString();
cmd.CommandType = CommandType.Text;
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
GridView1.DataSource = rdr;
GridView1.DataBind();
}
}
}
I am unable to write code by using BETWEEN Clause or use >= or <=
Also I need help on selecting "BOTH" in the Gender dropdowncombobox to get both Girls and Boys From age To age option.
Kindly help,
Thanks
Ravi
ravitv
15-May-21 11:49am
View
Great thanks,
I believe the link would give me some ray of hope to solve my problem.
Thanks Wendelius.
ravitv
15-May-21 7:32am
View
Great Member_10266297 for sharing this code without prejudice.
ravitv
7-Mar-21 4:23am
View
Nope. sorry I am still using 2008
ravitv
7-Mar-21 4:22am
View
Great advice like Griff suggested, Thanks you Patrice.
Please give any sample code or reference. Thanks.
ravitv
7-Mar-21 4:20am
View
Great advice Griff, Thanks.
Is there a sample code or any reference, please?
ravitv
7-Mar-21 4:13am
View
Sorry to spin a 10yr old Thread.
How to concatenate values from 3 combobox containing DD MM YYYY and then insert it in SQL Server 2008 using C#
What I did was...
protected void btnSubmit_Click1(object sender, EventArgs e)
{
if (IsControlsValid())
{
SqlConnection cn = new SqlConnection(@"Data Source=Admin-PC\SQLEXPRESS;Attac.........mdf;Integrated Security=True;User Instance=True");
String query = "Insert into EmployeeMaster(UserName,Password,BirthDate,Email) values(@UserName,@Password,@dob,@Email)";
SqlCommand cmd = new SqlCommand(query, cn);
int year = Convert.ToInt32(drpYYYY.SelectedItem.ToString());
int month = Convert.ToInt32(drpMM.SelectedItem.ToString());
int day = Convert.ToInt32(drpDD.SelectedItem.ToString());
DateTime dob = new DateTime(day, month, year);
cmd.Parameters.AddWithValue("@UserName", txtuname.Text);
cmd.Parameters.AddWithValue("@Password", txtupass.Text);
cmd.Parameters.AddWithValue("@BirthDate", dob);
cmd.Parameters.AddWithValue("@Email", emailID.Text);
try
{
cn.Open();
cmd.ExecuteNonQuery();
lblError.ForeColor = System.Drawing.Color.Red;
lblError.Text = "Employee Details Entered Successfully";
}
catch (Exception)
{
//Console.WriteLine("Error Generated. Details: " + e.ToString());
}
finally
{
cn.Close();
}
}
I dont use dateTimePicker - I use 3 Combobox.
Please Help.
Thanks
Ravi
ravitv
3-Mar-21 6:17am
View
Friends,
I need to insert an incremented value in ProfileId column(which is NOT a PrimaryKey) in a table by selecting Max(UId)+1 which IS a PrimaryKey from that same table and use cmd.Parameters.AddWithValue(.....,.....) along with other text values fetched from .aspx file.
I want to Concatnate "PM" with Max(UId)+1, for example PermanentMember and the desired value may be PM1, PM2, PM3....soon and soforth, where 1 2 3...is UID
I dont want to use Stored Procedure in SQL Server 2008.
What I did was.
protected void btnlogin_Click1(object sender, EventArgs e)
{
{
SqlConnection cn = new SqlConnection(@"Data Source=Admin-PC\SQLEXPRESS;AttachDbFilename=C:\Users\.......mdf;Integrated Security=True;User Instance=True");
String query = "Insert into EmpRegister(ProfileId,UserName,Password,Mobile,Email) SELECT MAX(UId)+1 as @ProfileID,@UserName,@Password,@Mobile,@Email)";
SqlCommand cmd = new SqlCommand(query, cn);
//Pass Values to parameters
cmd.Parameters.AddWithValue("@UserName", txtuname.Text);
cmd.Parameters.AddWithValue("@Password", txtupass.Text);
cmd.Parameters.AddWithValue("@Mobile", mobPhone.Text);
cmd.Parameters.AddWithValue("@Email", emailID.Text);
try
{
cn.Open();
cmd.ExecuteNonQuery();
//Console.WriteLine("Records Inserted Successfully");
}
catch (Exception)
{
//Console.WriteLine("Error Generated. Details: " + e.ToString());
}
finally
{
cn.Close();
}
}
}
Please help me where to insert this MAX(UId)+1 value in ProfileId column.
I tested the code without MAX(UId)+1 and removing SELECT MAX(UId)+1 as @ProfileID,@UserN...... from String query, works well.
Thanks for you time.
Ravi.
ravitv
22-Feb-21 9:44am
View
farremireia, Can you recollect what godaddy has guided, it will be useful for many followers. Thanks.
ravitv
22-Feb-21 9:41am
View
Yea, its true. I have to update myself as well as my software environment. Thanks for your suggestion.
Show More