We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

[48] SQL Commands

Last post 01-24-2007 7:18 AM by zible. 50 replies.
Page 4 of 4 (51 items) < Previous 1 2 3 4
Sort Posts: Previous Next
  • 10-20-2003 12:29 PM In reply to

    • athen
    • Not Ranked
    • Joined on 10-20-2003
    • New Member
    • Points 10

    SQL and VB

    Hi,

    I need to get the fields IDNO, Name, Email ID of a record...if the value of the field RETURN="Y". I have to use SQL statements for this. I'm totally new with this...plz help me...
    Also please tell me how to execute these commands in my program...
    Thanks in advance

    -Athen
    • Post Points: 0
  • 11-26-2003 1:44 AM In reply to

    • tomoko
    • Not Ranked
    • Joined on 11-26-2003
    • New Member
    • Points 10

    update data

    hi,
    pls help as i'm new in asp. i'm developing the administrative part of a website for my project. i'm having trouble with the "updating data" part. for example, i have done the 'add staff' and "delete staff' part with no problem. but how do i modify or update the data that i have previously added from the webpage. below are my codings. i have separated it into two asp files, the frmmodify.asp & frmmodifyprocess.asp. pls help.

    frmmodify.asp
    <html>
    <head>
    <title>modify customer</title>
    </head>
    <body>
    <%
    Set myconn=server.createobject("ADODB.Connection")

    dbpath="C:\Inetpub\wwwroot\final\greatscape.mdb"
    myconn.open "Provider=Microsoft.Jet.Oledb.4.0;Data source=" &dbpath


    name=request("name")
    address=request("address")
    phone=request("phone")
    Email=request("email")
    hphone=request("hphone")
    postcode=request("postcode")
    city=request("city")
    cusid=request("cus_id")

    set rs= Server.CreateObject("ADODB.Recordset")
    sql="Select * from Customers where cus_id=" &cusid
    rs.Open sql,myconn,1,2

       rs.update
        rs("name")=name
        rs("address")=address
        rs("phone")=phone
        rs("email")= Email
        rs("hphone")=hphone
        rs("postcode")=postcode
        rs("city")=city
       rs.update
    %>

    <form action="frmModify.asp" method="post">
    Name <input type=text name="name" value="<%=rs("name")%>">
    <br>
    Address <input type=text name="address" value="<%=rs("address")%>">
    <br>
    Phone <input type=text name="phone" value="<%=rs("phone")%>">
    <br>
    Email <input type=text name="email" value="<%=rs("email")%>">
    <br>
    Postcode <input type=text name="postcode" value="<%=rs("postcode")%>">
    <br>
    City <input type=text name="city" value="<%=rs("city")%>">
    <br>
    Hphone <input type=text name="hphone" value="<%=rs("hphone")%>">
    <br>
    <input type=submit value="Modify">
    </form>
    <%
    myconn.close
    set rs=nothing
    %>
    <a href="viewcustomer.asp">View Record Updated</a>
    </body>
    </body></html>

    frmmodifyprocess.asp
    <%
    dim myID
    Set myconn=server.createobject("ADODB.Connection")
    dbpath="C:\Inetpub\wwwroot\final\greatscape.mdb"
    myconn.open "Provider=Microsoft.Jet.Oledb.4.0;Data source=" &dbpath

    myID=Request.Form("cus_id")

    sql= "UPDATE Customers SET name='" &_
    Request.Form("name") &_
    "', address= '" & Request.Form("address")&_
    "', phone= '" & Request.Form("phone")&_
    "', state='" & Request.Form("state") &_
    "', hphone='" & Request.Form("hphone") &_
    "', postcode='" & Request.Form("postcode")&_
    "', city='" & Request.Form("city")&_
    "', WHERE cus_id= " &myID
    myconn.execute(sql)
    myconn.close
    set myconn=nothing
    %>
    <a href="viewcustomer.asp">View Record Updated</a>
    <html>
    <head>
    <title>modify customer</title>
    </head>
    <body>
    <BODY background="images/nabkgnd.jpg">
    <center>
    <H2>modify customer</H2></CENTER>
    <form id="Update" action="frmModifyProcess.asp"  method="POST" >
    <DIV align=center>
    <TABLE cellSpacing=0 cellP
    • Post Points: 0
  • 12-23-2003 3:29 AM In reply to

    Filling Table With Datagrid

    hey, i see how i can fill a datagrid with data from an sql table, but i am having trouble figuring out how to do the exact opposite, take data from a datagrid and fill an sql table with it/overriding the previous table, or just updating the previous table(adding new entries, changing changed one, and deleting deleted ones)

    any help would be greatly appreciated
    • Post Points: 0
  • 03-11-2004 12:55 PM In reply to

    Another database issue

    Basically am trying to search a database by getting an input from the users selection on a list.
    the list contains names of countries and when i click that search button, how can i get the result of the search, say like i click paris and in the database, the flight to paris has 8 more available seats and the date, how can i show this information, by using a datagrid? if so how can i link, i know there are alot of "how's" in there but i would be realy and trually greatful if u can spare a minute.
    • Post Points: 0
  • 04-25-2005 12:34 PM In reply to

    • darshan
    • Not Ranked
    • Joined on 04-25-2005
    • New Member
    • Points 10

    Sql Info

    you need to fire sql statement like this
    select idno, name, email, return from [table_name] where [your_condition]

    this will return record set lets say "rs" is object of recordset
    then you will need to check this in vb using next statement

    if rs("return")="Y" then
      'do something based on values you already have in recordset
      'like strEmail = rs("email")
    else
     'do something else
     'or do nothing
    end if

    this should solve your problem
    • Post Points: 10
  • 01-24-2007 7:18 AM In reply to

    • zible
    • Not Ranked
    • Joined on 01-24-2007
    • New Member
    • Points 5

    Check for Failed SQL Query

    This seems simple, yet I can't find how you do this. I need to run a query in VB on a very simple database. There is the possibility that the query would be unsuccessfull, and if so I need to do other actions, but I can't seem to figure out how to check for this and run other code, I just get a Runtime Error '3061' Too few parameters. Expected 1. 

    Here is my code:

     Dim MailDB As Database
     Dim RS As Recordset
     
       
        Dim SQL, eValue, PostieConfig, PP As String
       
        ' ----------------- '
        'if notify hasn't been set, use default value
        ' ----------------- '
        If notify = "" Then
            notify = "System"
        End If
           
       
        ' ----------------- '
        ' Open the Database on the Scheduler (currently NM16)
        ' ----------------- '
        Set MailDB = OpenDatabase("\\ORMNM16\DB$\email.mdb")
           
        ' ----------------- '
        ' SQL will retrive all email addresses
        ' matching system table and notify columns
        ' ----------------- '
       
        SQL = "Select Email From " & system & " Where " & notify & "=True"
        Set RS = MailDB.OpenRecordset(SQL)
         
        ' ----------------- '
        ' Verify a record exists and retrive first address
        ' ----------------- '
        If Not RS.EOF Then
            If Not RS!Email = "" Then
                eValue = RS!Email
            Else
                eValue = "nadcops@flowserve.com"
                notify = notify + " Not Found in Email Database"
            End If
        End If
       
        MsgBox eValue
        
        ' ----------------- '
        ' Loop through rest of addresses until verfication is complete
        ' ----------------- '
        Do While Not RS.EOF
            RS.MoveNext
                If Not RS.EOF Then
                    eValue = eValue + "," + RS!Email
                End If
        Loop
        ' ----------------- '
        ' Close Database and Recordset
        ' ----------------- '
        RS.Close
        MailDB.Close
    ::






















































    See I need to query the database to know who needs to get the email, dependent on notify returning true, and this works great if the script that calls this has a valid notify value.

    But there is a very very good chance that someone would put the wrong notify value in, or not include it in the DB, and what I would like to do, is if the query returns nothing to check for that so I can do other things (like send me an email saying this notify value doesn't exist in the DB)

    • Post Points: 5
Page 4 of 4 (51 items) < Previous 1 2 3 4