473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

sybase delete statement

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Sybase.Data.AseClient;

public partial class delete : System.Web.UI.Page
{
private AseConnection TempDMT_conn = new AseConnection(ConfigurationSettings.AppSettings["connectionString"]);

protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
string username = txtusername.Text;


TempDMT_conn.Open();


AseDataAdapter adapter = new AseDataAdapter();
adapter.MissingMappingAction = MissingMappingAction.Passthrough;
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

adapter.SelectCommand = new AseCommand(
"SELECT * FROM login WHERE username= @username ",
TempDMT_conn);
adapter.DeleteCommand = new AseCommand(
"DELETE FROM login WHERE username = @username",
TempDMT_conn);
adapter.DeleteCommand.UpdatedRowSource =
UpdateRowSource.None;
AseParameter parm = new AseParameter("@username",
AseDbType.Text, 10);
parm.SourceColumn = "username";
parm.SourceVersion = DataRowVersion.Original;
adapter.DeleteCommand.Parameters.Add(parm);


DataTable dataTable = new DataTable("login");
int rowCount = adapter.Fill(dataTable);

foreach (DataRow row in dataTable.Rows)
{
row.Delete();
}
int recordsAffected = adapter.Update(dataTable);


dataTable.Clear();



TempDMT_conn.Close();


}
}


how can i fix this error message
Must declare variable '@username'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Sybase.Data.AseClient.AseException: Must declare variable '@username'.


Source Error:


Line 50: int rowCount = adapter.Fill(dataTable);
Oct 31 '11 #1
0 1325

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: AlanAylett | last post by:
Hi all wondering if anybody could spot anything wrong with this SQL DELETE statement, both my Access and SQL skills are not what they used to be so i reckon its something simple, any suggestions...
1
by: Ian Davies | last post by:
I am using a simple delete statement in my php script (below) $q = "DELETE FROM commenttype WHERE TypeID=".$_POST; the problem is it doesnt delete the whole row it only deletes the text in one...
1
by: Matt | last post by:
I am writing a DELETE statement and I want to filter the records using another SELECT statement. My SELECT statement is a GROUP BY query that grabs all social security numbers from the "Data...
3
tolkienarda
by: tolkienarda | last post by:
hi all i have a loop that decides if a row should be deleted. i know i am getting into my if statement and that the variable that stores the id is correct but the delete statement wont work can...
0
by: crljenica | last post by:
I need to turn this select statement into a delete statemen. In other words, I want the results of the select statement deleted from the tables. I have never used a delete statement with a minus...
3
by: atrottier | last post by:
I'am new here so I'd like to say hello and this seems to be a great site it has already helped me a few times. I just got an assignment to correct and modify a simple access application. First some...
6
by: Carcus | last post by:
Hi I hope someone can help me with this one. I am writing a DELETE statement to run on a query I have set up called . I'm trying to delete all records with a and date that are matching. I'm...
3
by: zaiena | last post by:
hi, i'm working in asp.net using visual studio 2005 with vb language, my tables is access database, will i'm trying to write the delete statement to delete some fields in my tables i wrote this...
1
by: codedhacker | last post by:
I have a piece of code that uses the db-library with sql server 2000/2005 and runs the following delete statement: DELETE FROM TABLE1 WHERE COL1 IN( 'Some Val1' ) AND COL2 IN( 'Some Val2' )...
1
by: Ample | last post by:
I need a delete statement to delete records using the below select statement. I got a mind block as to what should be used in the where clause column operator. DELETE from InvOnHand WHERE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.