Solved

ASP.Net Update Query Parameters on Sybase

Posted on 2003-10-23
3
1,032 Views
Last Modified: 2012-06-21
Developing agains MS SQL is much easier and well documented for a new user.  My problem is that I am unable to complete an update query against a sybase Db.  I am able to connect to and query the Db but I do not know the syntax for adding parameters to the query.  My current page codes is below

Thanks in advance for the help.

<%@ Page CompilerOptions='/R:"C:\Program Files\Microsoft.NET\Odbc.Net\Microsoft.data.odbc.dll"' Debug="True"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Microsoft.Data.Odbc" %>

<HTML>
      <HEAD>

            <SCRIPT Language="VBScript" Runat="server">

            Sub Page_Load(Source as object, e as EventArgs)

            If not ISpostback then
                        
             Dim strSybase as String = "Driver={Sybase System 11};srvr=XXXXXX;Database=XXXXXX;UID=XXXXXX;PWD=XXXXXX;"
             Dim SybaseConn as ODBCConnection = new ODBCConnection(strSybase)
             Dim strSQLNull as string = "select po_no, queue_dt from asi_po_queue, asi_po_status where po_no = ord_line_ref_id and send_status = 97 and cust_status is null order by queue_dt desc"
             Dim NullQuery as ODBCDataAdapter = New ODBCDataAdapter(strSQLNull, SybaseConn)

            Dim NullDS as Dataset = new DataSet()
            NullQuery.fill(NullDS)
            
                  drpNull.DataSource = NullDS
                  drpNull.DataTextField = "po_no"
                  drpNull.DataValueField = "po_no"
                  drpNull.DataBind()

            end if

             Dim strconn as String = "Driver={Sybase System 11};srvr=XXXXXX;Database=XXXXXX;UID=XXXXXX;PWD=XXXXXX;"
             Dim conn as ODBCConnection = new ODBCConnection(strconn)
             Dim strSQL as string = "select po_no,queue_dt,send_status,ord_line_stat_desc,cust_status,ord_com_type,ord_com_com from asi_po_queue, asi_po_status where po_no = ord_line_ref_id order by queue_dt desc"
             Dim query as ODBCDataAdapter = New ODBCDataAdapter(strSQL, conn)

             Dim ds as Dataset = new DataSet()
             query.fill(ds)


             myDataGrid.DataSource = ds
             myDataGrid.DataBind()
      
                    

            End Sub
            
            

            
            
Sub btnUpdate_Click(sender As Object, e As ImageClickEventArgs)            
      Dim selectSQL as string = "update asi_po_queue set send_status = 0 where po_no=@po)"      
      Dim strNull as string
      strnull = drpnull.SelectedItem.value
      
      Dim nwindConn As OdbcConnection = New OdbcConnection("Driver={Sybase System 11};srvr=XXXXXX;Database=XXXXXX;UID=XXXXXX;PWD=XXXXXX;")
      Dim custDA As OdbcDataAdapter = New OdbcDataAdapter

      Dim selectCMD AS OdbcCommand = New OdbcCommand(selectSQL, nwindConn)
      custDA.SelectCommand = selectCMD

      ' Add Parameters and set values.
      selectCMD.Parameters.Add("@po", OdbcType.VarChar, 15).Value = strNull
                                Response.redirect ( "sybase.aspx" )
                         
            End Sub


            


            </SCRIPT >

      </HEAD>
      <BODY>
      
<form Runat="Server">

            


            There are <asp:Label id="lblNullCount" Runat="Server" /> orders that may need to be resubmitted.
            
             <asp:DropDownList
                  AutoPostBack="False"
                  id="drpNull"
                  runat="server"
                  Width="123px"
                  Font-Names="Tahoma"
                  Font-Size="8pt" />&nbsp;&nbsp;<asp:ImageButton ImageURL="/images/delete.gif" onclick="btnupdate_Click" runat="server" /></td>            
            <B>
            <p>
            *WARNING*<p></b>
            Always double check the ASI Transact website before resubmiting a PO. <BR>
            An error may have occured with the status update and not the PO submission.<BR>


 <FONT COLOR="Blue" FACE="Verdana" SIZE="2">PO's That have been submitted to ASI via Transact<BR><BR></FONT>

             <br>
             
<asp:ImageButton ImageURL="reset.gif" onclick="btnUpdate_Click" runat="server" />
             
             <Br>

             <ASP:DataGrid ID="MyDataGrid"       Runat="server" Font-Size="10pt" Font-Name="Verdana" AutoGenerateColumns="False" Border="0" Width="70%">
                  <AlternatingItemStyle BackColor="#cccccc" />
                        <Columns>
                              <asp:BoundColumn DataField="PO_NO" HeaderText="PO #"  />
                              <asp:BoundColumn DataField="queue_dt" HeaderText= "Date Sent"  />
                              <asp:BoundColumn DataField="send_status" HeaderText= "Status Code"  />
                              <asp:BoundColumn DataField="ord_line_stat_desc" HeaderText= "Status"  />
                              <asp:BoundColumn DataField="cust_status" HeaderText= "Status Description"  />
                              <asp:BoundColumn DataField="ord_com_type" HeaderText= "Comment Type"  />
                              <asp:BoundColumn DataField="ord_com_com" HeaderText= "Comment"  />
                        </Columns>

            </asp:DataGrid>
      </form>            

      </BODY>
</HTML>

0
Comment
Question by:Nuggets
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 250 total points
ID: 9609049
Nuggets,
Try this :
strNull = drpNull.SelectedItem.value
...

Instead of
selectCMD.Parameters.Add("@po", OdbcType.VarChar, 15).Value = strNull
Change to
selectCMD.Parameters.Add("@po", strNull)

selectCMD.ExecuteNonQuery()

x_com
0
 

Author Comment

by:Nuggets
ID: 9609190
Thanks
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9609436
Glad to help, Nuggets.

Regards
x_com
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change visitor's REMOTE_ADDR to server's REMOTE_ADDR 2 30
Button to go back 3 25
If condition on Html with Asp 11 15
innerHTML 7 16
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question