I thought I could help until I saw this...
Quote:
Originally Posted by ahlaj77
Using C# as the language in Visual Studio
|
I have a fairly extensive set of ASP programs which update a SQL database. The database is resident on the same server that provides the ASP pages.
Nevertheless, we established a DSN so that the connection would be smooth - which is okay in this application because the entire thing runs on a trusted network - no outside access. (You may not want to do it this way... I'm not sure.)
In the programs I have - first you define a string to contain your SQL command - using variables, this might look something like this:
' establish the conncetion:
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=SQLAUTO"
'begin building the SQL command string
strSQL = "Update TABLE_NAME Set"
strSQL = strSQL & " COLUMN_1 = '" & (Request.Form("COLUMN1.Value")) & "'"
strSQL = strSQL & ", COLUMN_2 = '" & Cstr(Request.Form("COLUMN2.Value")) & "'"
strSQL = strSQL & ", COLUMN_3 = '" & (Request.Form("SOLUMN3.Value")) & "'"
'optionally add some columns to update
' based on choices made during the first post of the page...
If Request.Form("RadioBtn_Value") = "Y" Then
strSQL = strSQL & ", COLUMN_4 = 'Y'"
Else
strSQL = strSQL & ", COLUMN_4 = 'N'"
End If
If Request.Form("RadioBtn2_Value") = "Y" Then
strSQL = strSQL & ", COLUMN_5 = 'Y'"
Else
strSQL = strSQL & ", COLUMN_5 = 'N'"
End If
'Then - add the 'where' condition
strSQL = strSQL & " Where pk_KEY = '" & variable_Key_Value & "'"
Set objCmd = Server.CreateObject("ADODB.Command")
adCmdText = 1
Set objCmd.ActiveConnection = conn
objCmd.CommandText = strSQL
objCmd.CommandType = adCmdText
' everything to here is preparation ... this line actually executes the QUERY
objCmd.Execute
' and don't forget to clean up after yourself.
'Close
Set objCmd = Nothing
conn.Close
Set conn = Nothing
Maybe you can translate this VB to C# for your use - if this doesn't really answer the question .. let us know ...
