Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have sql query
string strQuery = "DELETE FROM [USER] WHERE RoomID=" + Session["CURRENTROOM_ID"].ToString() + " AND ugid=" + strID;

i pass the ugid from another page and it work fine

i want to modify sql query to delete row where
ugid=" + strID
nick=" + strID1
ip=" + strID2
LoggedTime=" + strID3

i can pass all the value fine only need the sql query

i tried everything every time i get
error converting the nvarchar value to a column of data type int.

can anyone help me with that

note :
[ugid] [bigint] NOT NULL CONSTRAINT [DF_ChatUser_ugid] DEFAULT ((0)),
[nick] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ip] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LoggedTime] [datetime] NULL
Posted
Updated 30-Jun-11 10:21am
v2

k...
just try this
string a = strID1;
int x = new int();
x = int.parse(a);
 
Share this answer
 
Comments
akoyoon 30-Jun-11 18:43pm    
when i try this i get
'int' does not contain a definition for 'parse'
theanil 30-Jun-11 18:49pm    
Parse (capital p)
akoyoon 30-Jun-11 18:52pm    
now i get
System.Data.SqlClient.SqlException: Conversion failed when converting the nvarchar value 'akoyoon' to data type int.
int x = new int();
x = int.Parse(strID);

ugid=" + x
nick=" + strID1
ip=" + strID2
LoggedTime=" + strID3
 
Share this answer
 
v3
Comments
akoyoon 30-Jun-11 16:37pm    
it didnot work i get now error
'int' does not contain a definition for 'parse'
theanil 30-Jun-11 16:43pm    
it is working at my side.. i am updating it just check
akoyoon 30-Jun-11 16:47pm    
here is my page can you tell me what to do or how it suppose to be done

<%@ Page Language="C#" AutoEventWireup="true" %>
<% if (!IsPostBack)
{
if (Request.UrlReferrer == null)
Response.Redirect("/");

Session["EDIT_DS"] = null;
Session["ACTION"] = null;

string strID = Request.QueryString["ugid"];
string strID1 = Request.QueryString["nick"];
string strID2 = Request.QueryString["ip"];
string strID3 = Request.QueryString["LoggedTime"];
System.Data.SqlClient.SqlConnection SQLConnection = new System.Data.SqlClient.SqlConnection();
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SQLConnection.ConnectionString = ConnectionString;
if (SQLConnection.State == System.Data.ConnectionState.Closed)
SQLConnection.Open();
System.Data.DataSet ds = new System.Data.DataSet();
string strQuery = "DELETE FROM [USER] WHERE RoomID=" + Session["CURRENTROOM_ID"].ToString() + " AND ugid=" + strID;
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.CommandText = strQuery;
cmd.Connection = SQLConnection;
cmd.ExecuteNonQuery();
SQLConnection.Close();

Session["ACTION"] = "Delete";

Response.Redirect("../Main.aspx?Section=BlockedIPs");

} %>
theanil 30-Jun-11 16:47pm    
and if it also dosen't work then try this
Convert.ToInt32(strID1);
theanil 30-Jun-11 16:50pm    
Man you said me you want to pass nick but your code shows ugid
convert the value using
store the value in variable x
int.parse(x);
 
Share this answer
 
v2
Comments
akoyoon 30-Jun-11 16:22pm    
can you give me example for the query
theanil 30-Jun-11 16:26pm    
just a min...
theanil 30-Jun-11 16:27pm    
please let me know which column value you want to convert it to int
akoyoon 30-Jun-11 16:29pm    
column nick
theanil 30-Jun-11 16:33pm    
int x = int.parse(strID1);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900