473,505 Members | 14,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to set database execute statement

kirubagari
158 New Member
Hi Expert,
Kindly highlighten me how to set execute statement in the end of sql,
Attach is my code
Expand|Select|Wrap|Line Numbers
  1.      private void InsertintoDB()
  2.         {
  3.  
  4.             string strSQL = "";
  5.  
  6.             string strDBType = System.Configuration.ConfigurationManager.AppSettings["DBType"];
  7.             string strConn = System.Configuration.ConfigurationManager.AppSettings["DB_CONNECTION_STRING1"].ToString();
  8.             string strInsertTableName_Sql = "CIMMGR.[dbo].ANSDATA";
  9.             string strInsertTableName_Ora = "CIMMGR.ANSDATA";
  10.  
  11.  
  12.             if (strDBType == "MSSQL")
  13.             {
  14.                 strSQL = "Insert into " + strInsertTableName_Sql + "(EQID,CHAMBERID,MEMO,MESSAGE,REPORTTIME,PARAMETERID,RULEID,ALGORITHMVALUE,RULENAME,WAFER,ALARMACTION,RUNREUSLT)"
  15.                           + " Values(" + this.m_strEQID + "," + this.m_strChamberID + "," + this.m_strDescription + "," + this.m_strMessageText + "," + this.m_parameterId + "," + this.m_ruleId + "," + this.m_RunResult + "," + this.m_algorithmValue + "," + this.m_ruleName + "," + this.m_wafer + "," + this.m_strAlarmAction + "," + this.m_strProcessID + ")";
  16.  
  17.  
  18.             }
  19.             else
  20.             {
  21.                 strSQL = "Insert into " + strInsertTableName_Ora + "(EQID,CHAMBERID,MEMO,MESSAGE,REPORTTIME,PARAMETERID,RULEID,ALGORITHMVALUE,RULENAME,WAFER,ALARMACTION,RUNREUSLT)"
  22.                         + " Values(" + this.m_strEQID + "," + this.m_strChamberID + "," + this.m_strDescription + "," + this.m_strMessageText + "," + this.m_parameterId + "," + this.m_ruleId + "," + this.m_RunResult + "," + this.m_algorithmValue + "," + this.m_ruleName + "," + this.m_wafer + "," + this.m_strAlarmAction + "," + this.m_strProcessID + ")";
  23.  
  24.  
  25.             this.logger.LogMsg(@"[ANS] InsertIntoDB", true);
  26.             this.logger.LogMsg(@"[ANS] [SQL]: Insert into " + strInsertTableName_Ora + "(EQID,CHAMBERID,MEMO,MESSAGE,REPORTIME,PARAMETERID,RULEID,ALGORITHMVALUE,RULENAME,WAFER,ALARMACTION,VIEWEVENT)" + " Values(" + this.m_strEQID + "," + this.m_strChamberID + "," + this.m_strDescription + "," + this.m_strMessageText + "," + this.m_parameterId + "," + this.m_ruleId + "," + this.m_RunResult + "," + this.m_algorithmValue + "," + this.m_ruleName + "," + this.m_wafer + "," + this.m_strAlarmAction + "," + this.m_strProcessID + ")",true);
  27.             //return strSQL;
  28.  
  29.             }
  30.  
  31.         }
  32.         //Kiru 1.8.2012 End
  33.         #endregion
Dec 21 '12 #1
2 2258
PreethiGowri
126 New Member
check out this link you get complete details

http://www.csharp-station.com/Tutori.../Lesson01.aspx
Dec 21 '12 #2
HosseinKhoddami
2 New Member
use Like this statement

Expand|Select|Wrap|Line Numbers
  1. string strQuery = "INSERT INTO Table1(FirstName , LastName , Age) Values ( '{0}' , '{1}' , {2} ) ";
  2.  
  3. strQuery = string.Format(strQuery , txt_FirstName.Text , txt_LastName.Text , Convert.Toint32(txt_Age.Text));
  4.  
  5.  
  6. and Ten you can use strCommand in function like DoCommand(strQuery);
  7.  
  8.  
  9. using system.data.sqlclient; // imports sqlclient on top of your form or class
  10.  
  11. int DoCommand(string strCommand)
  12. {
  13. sqlConnection con = new sqlConnection("your connection string here");
  14. sqlCommand cmd = new sqlCommand(strCommand , con);
  15.  
  16. int i = 0;
  17. con.open();
  18. i=cmd.executeNonQuery();
  19. con.close();
  20.  
  21. return i;
  22.  
  23. }
Dec 25 '12 #3

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

Similar topics

4
7810
by: Arijit Chatterjee | last post by:
Dear Friens, I am writing a SP.But storeing a query in a variable.But at the time of execution generating error.Exam =================== Declare @query varchar{500) Set @query = 'Select * from...
1
2068
by: martin | last post by:
Hi, I have a page that contain a dropdown list of values. This drop down list rarely changes so I wish to cache the page. However the values in the dropdown box are taken from a database, so if...
3
1278
by: TJS | last post by:
trying to use code below to create dynamic variables but no success, what am I missing ? -------------------------- for i = 0 to 2 dim vString as string = "Dim submenu" & Cstr(i) & " As New...
1
1345
by: CSN | last post by:
I'm getting a bunch of these in my log: 2003-11-22 21:00:00 ERROR: syntax error at or near "s" at character 87 I think there might be an unescaped ' getting through. Is there a way to have...
7
28730
by: Cindy H | last post by:
Hi I'm having a problem getting the insert statement correct for an Access table I'm using. The Access table uses an autonumber for the primary key. I have tried this: INSERT INTO Tournaments...
3
2595
by: ChildProgrammer | last post by:
I am trying to upload data into an Access db from vb.net. The data was parsed out from text files. Everything seems to be working fine up till the .execute point. The debugger insists there is a...
5
5840
by: ravysters | last post by:
hi.. i know that to execute dynamic statements in postgres we have the EXECUTE statement.. but postgres support the execute using statement like in oracle...
12
1085
by: Earl Partridge | last post by:
I just downloaded this VB Express. I need a little help in understanding the request for database data, that is the format/syntax compared to an SQL statement. In my SQL I would use a select...
1
2243
by: fran7 | last post by:
Hi, I wonder if anyone can advise. One database field is never empty as I have a text editor that inputs <P>&nbsp;</P> even if I dont actually put any text. I need to check with an if statement if...
3
6291
by: osman7king | last post by:
I use the EXECUTE statement in a procedure which has 2 parameters, one is to hold the query, and the other for the value used in the query create or replace function delete_from_table1(character...
0
7216
marktang
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,...
0
7098
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
7303
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
7367
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...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
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...
0
4699
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
3187
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
3176
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.