Click here to Skip to main content
15,899,026 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Gridview SortExpression Pin
deep719-Jul-07 1:37
deep719-Jul-07 1:37 
Questiondisplaying latest 5 values from database table in datagrid Pin
mavii19-Jul-07 0:59
mavii19-Jul-07 0:59 
AnswerRe: displaying latest 5 values from database table in datagrid Pin
Eduard Keilholz19-Jul-07 1:02
Eduard Keilholz19-Jul-07 1:02 
GeneralRe: displaying latest 5 values from database table in datagrid Pin
Sonia Gupta19-Jul-07 1:46
Sonia Gupta19-Jul-07 1:46 
GeneralRe: displaying latest 5 values from database table in datagrid Pin
Eduard Keilholz19-Jul-07 2:29
Eduard Keilholz19-Jul-07 2:29 
AnswerRe: displaying latest 5 values from database table in datagrid Pin
Sathesh Sakthivel19-Jul-07 1:03
Sathesh Sakthivel19-Jul-07 1:03 
AnswerRe: displaying latest 5 values from database table in datagrid Pin
Md Mustafa19-Jul-07 2:04
Md Mustafa19-Jul-07 2:04 
Questionuploaded problem Pin
saravanan0519-Jul-07 0:35
saravanan0519-Jul-07 0:35 
hi friends

this is my stored procedure

CREATE procedure dbo.sp_ins_logo
@companyname varchar(120),
@country varchar(80),

@url varchar(150),
@category varchar(80),
@description varchar(250),
@picturepath varchar(80),
@picturetype char(5),
@status int,


@ins_status varchar(10) output,
@lcode varchar(10) output
as
set nocount on
begin transaction

declare @logo_rowid decimal
declare @logo_code varchar(10)


declare @logo_rowcount decimal


declare @max_logoid decimal

declare @logo_codepfix char(3)


set @logo_codepfix='LGO'

select @logo_rowcount= (select count(*) from dbo.tbladdlogos1)


if @logo_rowcount = 0
begin
select @logo_rowid = 1
select @logo_code = @logo_codepfix + convert(varchar(5),@logo_rowid)

end
else
begin
select @max_logoid = (select max(row_id) from dbo.tbladdlogos1)
set @logo_rowid = @max_logoid + 1
set @logo_code = @logo_codepfix + convert(varchar(5),@logo_rowid)
end


declare @file_name varchar(80)
set @file_name = @picturepath + @logo_code + '.' + @picturetype

if not exists (select companyname from dbo.tbladdlogos1 where url = @url)
begin
if not exists (select companyname from dbo.tbladdlogos1 where companyname = @companyname)
begin
insert into dbo.tbladdlogos1 values(@logo_rowid,@logo_code,@companyname,@country,@url,@category,@description,@file_name,@status)


declare @ER as int
select @ER = @@error
if @ER <> 0
begin
set @ins_status='Failure'
set @lcode=@logo_code
end
else
begin
set @ins_status='Success'
set @lcode=@logo_code
end
end
end

commit

GO


this is my codebehind

Try
Dim companyName, categoryName, countryName As String
Dim url, description, other, inFilename, fileType, path, ccategory As String
Dim status As Integer
companyName = txtcompany.Text
ccategory = txtcategory.Text
countryName = ddcountry.SelectedItem.Text
status = 0
url = txturl.Text


description = txtdescrip.Text
path = "images\logos\country\"
inFilename = myFile.PostedFile.FileName
fileType = inFilename.Substring((inFilename.IndexOf(".")) + 1, ((Len(inFilename)) - inFilename.IndexOf(".")) - 1)
strConnString = obj.GetConnectionString()
conn = obj.GetDbConnection(strConnString)

' create a sql comman using the query string and the DBconnection

myCommand = New SqlCommand("sp_ins_logo", conn)
myCommand.CommandType = CommandType.StoredProcedure

Dim objParam As SqlParameter

objParam = myCommand.Parameters.Add("@companyname", SqlDbType.VarChar, 120)
objParam.Direction = ParameterDirection.Input
objParam.Value = companyName

objParam = myCommand.Parameters.Add("@country", SqlDbType.VarChar, 80)
objParam.Direction = ParameterDirection.Input
objParam.Value = countryName


objParam = myCommand.Parameters.Add("@url", SqlDbType.VarChar, 150)
objParam.Direction = ParameterDirection.Input
objParam.Value = url

objParam = myCommand.Parameters.Add("@category", SqlDbType.VarChar, 80)
objParam.Direction = ParameterDirection.Input
objParam.Value = ccategory

objParam = myCommand.Parameters.Add("@description", SqlDbType.VarChar, 250)
objParam.Direction = ParameterDirection.Input
objParam.Value = description


objParam = myCommand.Parameters.Add("@picturepath", SqlDbType.VarChar, 80)
objParam.Direction = ParameterDirection.Input
objParam.Value = path

objParam = myCommand.Parameters.Add("@picturetype", SqlDbType.Char, 5)
objParam.Direction = ParameterDirection.Input
objParam.Value = fileType

objParam = myCommand.Parameters.Add("@status", SqlDbType.Int)
objParam.Direction = ParameterDirection.Input
objParam.Value = status

objParam = myCommand.Parameters.Add("@ins_status", SqlDbType.VarChar, 10)
objParam.Direction = ParameterDirection.Output

objParam = myCommand.Parameters.Add("@lcode", SqlDbType.VarChar, 10)
objParam.Direction = ParameterDirection.Output

myCommand.ExecuteNonQuery()


Dim insStatus, insCode As String

insStatus = myCommand.Parameters("@ins_status").Value


insCode = myCommand.Parameters("@lcode").Value


If insStatus = "Success" Then
Dim statusOutput As String

If statusOutput = "Success" Then
lblMsg.Visible = True
lblMsg.ForeColor = Color.DarkGreen
lblMsg.Text = "Your Logo was uploaded successfully."
Else
Dim delQuery As String
delQuery = "delete from tbladdlogos1 where logo_code='" & insCode & "'"
myCommand = New SqlCommand(delQuery, conn)
myCommand.ExecuteNonQuery()

lblMsg.ForeColor = Color.Red
lblMsg.Text = statusOutput
End If

ElseIf insStatus = Nothing Then
lblMsg.ForeColor = Color.Red
lblMsg.Text = "Problem in uploadig your Logo, Please Try again Later..!"
Else
lblMsg.ForeColor = Color.Red
lblMsg.Text = "you have already uploaded the logo for this comapny"
End If

Catch ex As Exception

Response.Write(ex.Message)
Finally
If (Not conn Is Nothing) Then
' objCsDataBase.CloseDbConnection(conn)
End If
End Try
End Sub


my problem is:

I have four texboxs

1.company name
2.url
3.category
4.description
5.fileupload

here ,i wrote the storedprocdure the users entered the company one time only

next time he entered same comapany the "you have already uploaded the logo for this comapny" this text is displayed

but i entered next time i got error like this

"Cast from type 'DBNull' to type 'String' is not valid"


plz help me


regards
saravanan
AnswerRe: uploaded problem Pin
Sathesh Sakthivel19-Jul-07 0:43
Sathesh Sakthivel19-Jul-07 0:43 
GeneralRe: uploaded problem Pin
saravanan0519-Jul-07 1:15
saravanan0519-Jul-07 1:15 
GeneralRe: uploaded problem Pin
Sathesh Sakthivel19-Jul-07 1:18
Sathesh Sakthivel19-Jul-07 1:18 
GeneralRe: uploaded problem Pin
saravanan0519-Jul-07 1:37
saravanan0519-Jul-07 1:37 
GeneralRe: uploaded problem Pin
Sathesh Sakthivel19-Jul-07 2:07
Sathesh Sakthivel19-Jul-07 2:07 
QuestionDrag and Drop control in asp.net Pin
Milind Panchal19-Jul-07 0:11
Milind Panchal19-Jul-07 0:11 
AnswerRe: Drag and Drop control in asp.net Pin
sathesh pandian19-Jul-07 2:07
sathesh pandian19-Jul-07 2:07 
QuestionConvert apsx page to AJax enabled site Pin
Archana New to Dotnet19-Jul-07 0:02
Archana New to Dotnet19-Jul-07 0:02 
AnswerRe: Convert apsx page to AJax enabled site Pin
Imran Khan Pathan19-Jul-07 0:20
Imran Khan Pathan19-Jul-07 0:20 
GeneralRe: Convert apsx page to AJax enabled site Pin
Archana New to Dotnet19-Jul-07 0:55
Archana New to Dotnet19-Jul-07 0:55 
AnswerRe: Convert apsx page to AJax enabled site Pin
Sylvester george19-Jul-07 0:23
Sylvester george19-Jul-07 0:23 
GeneralRe: Convert apsx page to AJax enabled site Pin
Archana New to Dotnet19-Jul-07 0:55
Archana New to Dotnet19-Jul-07 0:55 
QuestionHow to create a Folder Pin
Amit.Amit.Amit...18-Jul-07 23:24
Amit.Amit.Amit...18-Jul-07 23:24 
AnswerRe: How to create a Folder Pin
N a v a n e e t h18-Jul-07 23:50
N a v a n e e t h18-Jul-07 23:50 
GeneralRe: How to create a Folder Pin
Amit.Amit.Amit...19-Jul-07 0:06
Amit.Amit.Amit...19-Jul-07 0:06 
QuestionEnable & disable AutopostBAck at client side Pin
samerh18-Jul-07 23:07
samerh18-Jul-07 23:07 
AnswerRe: Enable & disable AutopostBAck at client side Pin
Sandeep Akhare18-Jul-07 23:11
Sandeep Akhare18-Jul-07 23:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.