J
Jan Nielsen
Hi
I would like to use a stored procedure to return a city from a zip and
return "unknown" if no zip or a non-excisting zip is entered
I have this code that only works on existing zips:
********************
Dim myCommand As New SqlCommand("ReturnerByFraPostnr", SqlConnectionFindBy)
Dim retRow As String
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.Add("@postnr", SqlDbType.Int).Value =
txtPostnummer.Text
If txtPostnummer.Text = "" Then
txtBy.Text = ""
Exit Sub
End If
If SqlConnectionFindBy.State = ConnectionState.Closed Then
SqlConnectionFindBy.Open()
retRow = myCommand.ExecuteScalar
txtBy.Text = retRow
Else
retRow = myCommand.ExecuteScalar
txtBy.Text = retRow
End If
myCommand = Nothing
************************
Here is my stored procedures sql
CREATE PROCEDURE [dbo].[ReturnerByFraPostnr]
@postnr int --,
AS
select [by] from tPostnr where Postnr = @postnr
GO
*******************************
Best regards
Jan
I would like to use a stored procedure to return a city from a zip and
return "unknown" if no zip or a non-excisting zip is entered
I have this code that only works on existing zips:
********************
Dim myCommand As New SqlCommand("ReturnerByFraPostnr", SqlConnectionFindBy)
Dim retRow As String
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.Add("@postnr", SqlDbType.Int).Value =
txtPostnummer.Text
If txtPostnummer.Text = "" Then
txtBy.Text = ""
Exit Sub
End If
If SqlConnectionFindBy.State = ConnectionState.Closed Then
SqlConnectionFindBy.Open()
retRow = myCommand.ExecuteScalar
txtBy.Text = retRow
Else
retRow = myCommand.ExecuteScalar
txtBy.Text = retRow
End If
myCommand = Nothing
************************
Here is my stored procedures sql
CREATE PROCEDURE [dbo].[ReturnerByFraPostnr]
@postnr int --,
AS
select [by] from tPostnr where Postnr = @postnr
GO
*******************************
Best regards
Jan