473,472 Members | 2,181 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem with insert statement in asp.net

109 New Member
I have two problem.

1) My insert statement here is not working.

It is not inserting value into the database. I am not getting any error message but I can not figured out why it is not inserting the value into database.

Please help me it is very urgent.

Thank You,



Expand|Select|Wrap|Line Numbers
  1. int max = 0;
  2.             sqidate = DateTime.Now.ToString("yyMM");
  3.             Response.Write("Today's date is:" +sqidate);
  4.             int qdate = Convert.ToInt32(sqidate);
  5.             SqlCommand qicmd = new SqlCommand();
  6.             //SqlDataReader qireader = new SqlDataReader();
  7.             qicmd.Connection = sqlConnection1;
  8.             qicmd.Connection.Open();
  9.             qicmd.CommandText = " select QI_TRACK from gingercqi where QI_TRACK like '"+qdate+"%' ";
  10.             qicmd.ExecuteNonQuery();
  11.             SqlDataReader qireader = qicmd.ExecuteReader();
  12.  
  13.             int temp = -1;
  14.  
  15.             if(!qireader.Read())
  16.             {
  17.                 txtqitrack.Text = sqidate + 01;    
  18.                 qicmd.CommandText = "insert into gingercqi(QI_TRACK) values ('"+txtqitrack.Text+"')";
  19.             }
  20.  
  21. qireader.Close();
  22. qicmd.Connection.Close();
  23.  

Expand|Select|Wrap|Line Numbers
  1. (Problem 2)
  2. can I write insert statement like this: using a where clause.
  3.  
  4. cmd.CommandText = "insert into gingercqi (QI_TRACK,DATE_RCV,INC_NUM,INC_DATE,INC_TIME,QANUM,BASE_HSP,ISSUE_IDENTIFY,MICN_INVOLVED,[1ST_RESP1],[1ST_RESP2],TRANSPORT1) VALUES ('"+txtqitrack.Text+"','"+Datercv.SelectedDate+"','"+ txtincnum.Text+"','"+ Dateinc.SelectedDate+"','"+txtinctime.Text+"','"+txtqanum.Text+"','"+ dpbasehsp.SelectedValue +"','"+dpissueidentify.SelectedValue+"','"+txtmicninvl.Text+"','"+txt1stresp1.Text+"','"+txt1stresp2.Text+"','"+txttransport1.Text+"') where QI_TRACk = '"+txtqitrack.Text+"'";
  5.  
Thank You,
Nov 29 '07 #1
1 1039
nguyenlh
25 New Member
I think that !!
you Open Sql and try query - with your query
if you can run in SQL - after you run in C#
Nov 30 '07 #2

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

Similar topics

3
by: Jason Callas | last post by:
I have a stored procedure that runs as a step in a scheduled job. For some reason the job does not seem to finish when ran from the job but does fine when run from a window in SQL Query. I know...
5
by: Ritesh | last post by:
Hi All, According to my observation using SP_WHO2 in my database, some INSERT statements are getting blocked by SELECT statements. Though the blocking SELECT statement is having ReadPast hint,...
4
by: Dani | last post by:
Hi everyone Description of the problem: Using a PreparedStatement to write down an integer (int) plus a timestamp for testing purposes. When read out again the integer looks very different. We...
4
by: Bradley Burton | last post by:
I'm using Allen Brown's code for audit logging (http://allenbrowne.com/AppAudit.html), but I'm having a problem. My aud table doesn't populate with the tracking info at all. I think it might be a...
3
by: alexmaster_2004 | last post by:
hi i have made an application using C# that access sql2000. this application is just used to insert data to the database. i use something like this in my code: // string colmnA = TextBox1.Text;...
9
by: Jack | last post by:
Hi, I am gathering the input values to a form using Request.form method from the processing page. After all the data is captured, I am building sql statement out of it. Using a response.write...
2
by: mob1012 via DBMonster.com | last post by:
Hi All, I wrote last week about a trigger problem I was having. I want a trigger to produce a unique id to be used as a primary key for my table. I used the advice I received, but the trigger is...
22
by: b_r | last post by:
Hi, I'm trying to make a simple operation (insert into DB) in VB 2005 and SQL Server. The code is as follows: Dim sConnectionString As String = _ "Data...
8
by: Red | last post by:
If auto-format is turned off in VS2008, there is apparently no way to indent a line. Under Tools->Options->Text Editor->C#->Formatting, there are three checkboxes. Unchecking those seems to cause...
1
by: Maklar60 | last post by:
I am attempting to execute an INSERT statement on my page but continually get the following error: Microsoft OLE DB Provider for ODBC Drivers error '80040e14' Incorrect syntax near '<'. ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.