?
Solved

ASP.Net Update Query Parameters on Sybase

Posted on 2003-10-23
3
Medium Priority
?
1,043 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 1000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

762 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