Solved

ASP.Net Update Query Parameters on Sybase

Posted on 2003-10-23
3
1,029 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
Comment Utility
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
Comment Utility
Thanks
0
 
LVL 29

Expert Comment

by:David H.H.Lee
Comment Utility
Glad to help, Nuggets.

Regards
x_com
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
X-Frame-Options - click-jacking 7 45
Replacing smart quotes from word 7 61
syntax error on ASP ? 6 39
two submit buttons one form 15 65
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 …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now