When i am running this query its gvng an syntax error near where statement.. -
SqlCommand cmd2 = new SqlCommand("Update Personal_Profile set city='" + txtcity.Text + "',"+"hometown='" + txttown.Text + "',"+"iam='" + gender + "',"+"interestedin='" + interested + "',"+"languages='" + txtlang.Text + "',"+"aboutme='" + txtabtme.Text + "',"+"phno='" + txtmobileph.Text + "relationship='" + relationship +"','"+"where (username = '"+unm +"')", con);
-
cmd2.ExecuteNonQuery();
-
2 1264
You have an error in the separators between parts just after the phone number.
You have this at present: - +"phno='" + txtmobileph.Text + "relationship='" + relationship +"','"+"where (username = '"+unm +"')"
but it should be - +"phno='" + txtmobileph.Text + "', relationship='" + relationship +"' WHERE (username = '"+unm +"')"
-Stewart
Thnks... D error has been removed .. But d values are still not being updated... - protected void Button1_Click(object sender, EventArgs e)
-
{
-
con = new SqlConnection(cns);
-
string unm = Session["uname"].ToString();
-
string gender;
-
gender = DropDownList1.SelectedValue.ToString();
-
string interested;
-
if (chkmale.Checked == true)
-
interested = "male";
-
else
-
interested = "female";
-
string relationship;
-
relationship = DropDownList2.SelectedValue.ToString();
-
con.Open();
-
SqlCommand cmd1 = new SqlCommand("Select * from Personal_Profile where username ='" + unm + "'", con);
-
SqlDataReader dr = cmd1.ExecuteReader();
-
if (dr.Read())
-
{
-
if (dr.HasRows == false)
-
{
-
cmd = new SqlCommand("insert into Personal_Profile values('" + unm + "','" + txtcity.Text + "','" + txttown.Text + "','" + gender + "','" + interested + "','" + txtlang.Text + "','" + txtabtme.Text + "','" + txtmobileph.Text + "','" + relationship + "')", con);
-
cmd.ExecuteNonQuery();
-
}
-
else
-
{
-
con.Close();
-
con.Open();
-
SqlCommand cmd2 = new SqlCommand("Update Personal_Profile set city='" + txtcity.Text + "',"+"hometown='" + txttown.Text + "',"+"iam='" + gender + "',"+"interestedin='" + interested + "',"+"languages='" + txtlang.Text + "',"+"aboutme='" + txtabtme.Text + "',"+"phno='" + txtmobileph.Text + "',relationship='" + relationship +"'where username = '"+unm +"'", con);
-
cmd2.ExecuteNonQuery();
-
con.Close();
-
}
-
}
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Lisa |
last post by:
can someone tell me what is wrong with this query? I've tried every
combo that I can think of - adding &,"", "'", ) everywhere I can think
of and I keep getting an 'Expected end of statement...
|
by: Steve Bishop |
last post by:
I'm having problems using an update query. I get the error: Server: Msg
8152, Level 16, State 9, Procedure SP_MemberUpdate, Line 3
String or binary data would be truncated.
The statement has been...
|
by: Nicolae Fieraru |
last post by:
Hi All,
I was trying to update a field in a table, based on the results from a
query.
The table to be updated is tblCustomers and the query is qrySelect. This
query has two parameters, provided...
|
by: Randy Harris |
last post by:
I imported records into a table, later found out that many of them had
trailing spaces in one of the fields. If I'd caught it sooner, I could have
trimmed the spaces before the import.
This...
|
by: deko |
last post by:
I'm trying to update the address record of an existing record in my mdb with
values from another existing record in the same table. In pseudo code it
might look like this:
UPDATE tblAddress SET...
|
by: Mark Carlyle via AccessMonster.com |
last post by:
I have this update query that I am trying to run. I know the syntax is
messed up but do not know how to correct it.
Select 'UPDATE', Transactions,'Set = where =
' From "Get Daily Balances"
...
|
by: Greg Strong |
last post by:
Hello All,
In an 'Update' query can you use user-defined functions in the 'Update
To' for the query? Either no or I'm missing something. See the
additional info below.
If I run a query...
|
by: DP |
last post by:
hi,
i;ve created an update query, which WORKS!!,
i've got an update to check a checkbox in a film table,
and i've got another update query to uncheck a checkbox, when a record is
deleted.
...
|
by: Reedsp |
last post by:
OS: MS XP
Access version: 2003 SP2
I am trying to use an update query to replace quote marks with nothing. In essence, I'm removing quote marks. I get a error message when a field is empty or...
|
by: MindBender77 |
last post by:
Hello again, All...
Admin's, I wasn't sure where to post this, please move if in wrong forum.
I'm using FrontPage 2003 to post form data to a second form to be used in an update query. The query...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |