Hi

I have a site with 2 pages. The first page consists of a set of input fields where the data input by the users will end up in a db when the user clicks the submitt button, creating a new record.

As well as this on click the users is taken to page 2 and the VesselName (one of fields on page one) value is passed to the second page via the URL and then read into a field in the second page.

I need to display the new record's ID or Ref (as I have called it) of the new record created in page 1 based on the VesselName that passed on the URL in page 2

THanks

hi,

u can use sql query to retrieve that

string query="select rfid from table where vesselname="+request.querystring["vesselname"]

hi,

u can use sql query to retrieve that

string query="select rfid from table where vesselname="+request.querystring["vesselname"]

Thanks greeny I tried what you suggested and got the following error
Value of type 'System.Collections.Specialized.NameValueCollection' cannot be converted to 'Integer'
Here is my code

<script runat="server">
Sub Page_Load()
Dim r As Integer
if Request.QueryString("VesselName") is nothing then
VesselName.Text = "Blank Name" 'some default value
else
VesselName.Text = Request.QueryString("VesselName")'this works fine
r = "SELECT Ref FROM Returns WHERE VesselName="(request.querystring["VesselName"])""
Ref.Text = r
end if
End Sub
</script>

hi,

try like this

string vessel=request.querystring["VesselName"];

string strsql = "SELECT Ref FROM Returns WHERE VesselName='"+vessel+"";

for this code to work you need to connect to database
try
{
sqlconnection conn=new sqlconnection("u r database string");
conn.open();
sqlcommand cmd=new sqlcommand(strsql,conn);
int ref=(int)cmd.executescalar();
}
catch (Exception ex)
{
}
finally
{
conn.close();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.