Solved

ASP.Net Update Query Parameters on Sybase

Posted on 2003-10-23
3
1,041 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
[X]
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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 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