Click here to Skip to main content
15,919,778 members
Home / Discussions / Database
   

Database

 
AnswerRe: Case sensitive queries? Pin
Richard Deeming24-Mar-03 7:34
mveRichard Deeming24-Mar-03 7:34 
GeneralADO + SQL + FOXPRO Question/problem Pin
iluha22-Mar-03 11:11
iluha22-Mar-03 11:11 
GeneralRe: ADO + SQL + FOXPRO Question/problem Pin
Marek Konieczny27-Mar-03 1:43
Marek Konieczny27-Mar-03 1:43 
QuestionSQL interactive training? Pin
Duncan Edwards Jones21-Mar-03 0:05
professionalDuncan Edwards Jones21-Mar-03 0:05 
GeneralSQL Performance UserConnections Pin
Peter Kiss20-Mar-03 12:44
Peter Kiss20-Mar-03 12:44 
GeneralODBC and CListCtrl Pin
MemLeak20-Mar-03 10:17
MemLeak20-Mar-03 10:17 
GeneralAdding New records to Access DB Pin
Aaron Schaefer19-Mar-03 9:31
Aaron Schaefer19-Mar-03 9:31 
GeneralProblem using UPDATE Pin
Steve McLenithan19-Mar-03 2:51
Steve McLenithan19-Mar-03 2:51 
Hey everyone,

I am using an SQL Server 2000 database. It holds a table whose records have to be updated. I thought I had the query right, but it doesn't do anything. I am concatenating the sql string like this (I will be doing more validation later):

string sql = "UPDATE MYdotNET_addressbook" +
" SET [firstName] = '" + firstname.Text + "'," +
" [lastName] = '" + lastname.Text + "'," +
" [emailPrim] = '" + emailprim.Text + "'," +
" [emailSec] = '" + emailsec.Text + "'," +
" [company] = '" + company.Text + "'," +
" [jobTitle] = '" + jobtitle.Text + "'," +
" [businessPhone] = '" + bphone.Text + "'," + 
" [homePhone] = '" + hphone.Text + "'," +
" [mobilePhone] = '" + mobilephone.Text + "'," +
" [businessFax] = '" + bfax.Text + "'," +
" [homeFax] = '" + hfax.Text + "'," +
" [website] = '" + website.Text + "'," +
" [msnAddy] = '" + msnaddy.Text + "'," +
" [birthday] = convert(datetime,'" + birthday.Text + "')," +
" [addressHomeSt] = '" + hst.Text + "'," +
" [addressHomeCity] = '" + hcity.Text + "'," +
" [addressHomeState] = '" + hstate.Text + "'," +
" [addressHomeZip] = convert(int,'" + hzip.Text + "')," +
" [addressBizSt] = '" + bstreet.Text + "'," +
" [addressBizCity] = '" + bcity.Text + "'," +
" [addressBizState] = '" + bstate.Text + "'," +
" [addressBizZip] = convert(int,'" + bzip.Text + "')," +
" [nickname] = '" + nickname.Text + "'" +
"WHERE (id = '" + Convert.ToInt32(Request.Params["id"]) + "')";

UpdateData(sql);


The UpdateData method looks like this:

private void UpdateData(string sql)
{
	try
	{
		DataSource db = new DataSource();
		SqlConnection conn = new SqlConnection(db.DbString);
		SqlCommand cmd = new SqlCommand(sql, conn);
		cmd.CommandType = CommandType.Text;
		conn.Open();
		cmd.ExecuteNonQuery();
		conn.Close();
		Response.Redirect("addressBook.aspx");
	}
	catch (Exception e)
	{
		Response.Write(e.Message + "<hr/>" + e.Source + "<hr/>" + e.StackTrace);
	}
}


As it stands now, I don't get any errors, it just doesn't do the update. I can't figure out why.

Is my sql string wrong?Confused | :confused: Confused | :confused: Confused | :confused:

I know this isn't the asp.net forum, but I thought it would be more relevant here.

$TeVe McLeNiThAn

confused:Confused | :confused: Confused | :confused:

I know this isn't the asp.net forum, but I thought it would be more relevant here.

$TeVe McLeNiThAn

GeneralRe: Problem using UPDATE Pin
Philip Patrick19-Mar-03 10:03
professionalPhilip Patrick19-Mar-03 10:03 
GeneralRe: Problem using UPDATE Pin
Steve McLenithan20-Mar-03 10:40
Steve McLenithan20-Mar-03 10:40 
GeneralRe: Problem using UPDATE Pin
Philip Patrick20-Mar-03 10:56
professionalPhilip Patrick20-Mar-03 10:56 
GeneralRe: Problem using UPDATE Pin
Rein Hillmann21-Mar-03 10:08
Rein Hillmann21-Mar-03 10:08 
GeneralRe: Problem using UPDATE Pin
Steve McLenithan21-Mar-03 12:27
Steve McLenithan21-Mar-03 12:27 
GeneralRe: Problem using UPDATE Pin
Rein Hillmann21-Mar-03 13:20
Rein Hillmann21-Mar-03 13:20 
GeneralRe: Problem using UPDATE Pin
Steve McLenithan21-Mar-03 13:53
Steve McLenithan21-Mar-03 13:53 
GeneralRe: Problem using UPDATE [ prob Narrowed down!!] Pin
Steve McLenithan21-Mar-03 20:16
Steve McLenithan21-Mar-03 20:16 
GeneralRe: Problem using UPDATE Pin
SimonS22-Mar-03 1:41
SimonS22-Mar-03 1:41 
GeneralRe: Problem using UPDATE Pin
Richard Deeming24-Mar-03 7:44
mveRichard Deeming24-Mar-03 7:44 
GeneralRe: Problem using UPDATE Pin
Steve McLenithan24-Mar-03 7:46
Steve McLenithan24-Mar-03 7:46 
GeneralAny Access experts here Pin
Michael P Butler18-Mar-03 23:13
Michael P Butler18-Mar-03 23:13 
GeneralRe: Any Access experts here Pin
Jeremy Oldham19-Mar-03 1:39
Jeremy Oldham19-Mar-03 1:39 
GeneralRe: Any Access experts here Pin
Michael P Butler19-Mar-03 3:25
Michael P Butler19-Mar-03 3:25 
GeneralDBConcurrencyException: Delete a entry in master -detail table Pin
DionChen18-Mar-03 10:16
DionChen18-Mar-03 10:16 
QuestionAlternatives to Access??? Pin
LukeV18-Mar-03 3:05
LukeV18-Mar-03 3:05 
AnswerRe: Alternatives to Access??? Pin
LukeV18-Mar-03 9:36
LukeV18-Mar-03 9:36 

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.