Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ASP.Net Update Query Parameters on Sybase

Posted on 2003-10-23
3
1,036 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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