Please help...ASP and SQL Stored Procedure

Results 1 to 2 of 2

Thread: Please help...ASP and SQL Stored Procedure

  1. #1
    Anthony Nguyen Guest

    Default Please help...ASP and SQL Stored Procedure

    Please help..<BR>I&#039m very new at ASP. I&#039m having this project at work which I have to wirte some ASP code to allow the database administrator to create a new table in my company database from the web. I used the store procedure to do that in my code, but I had a error message saying that "The application is using arguments that are of the wrong type, are out of accpetable range, or are in conflict with one another". Please take a look at my code and correct it for me!!! All the helps are highly appreciated..Thanks a lot. Best wishes to all of you.<BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;!--#include file = "init.asp"--&#062;<BR><BR><BR>&#060;% <BR>&#039Clean out single quotes and double quotes in a string<BR><BR>Function CleanString(strValue)<BR> Dim strTemp<BR> strTemp = strValue<BR> <BR>&#039clean out single quotes<BR><BR> Do Until InStr(1,strTemp,"&#039") = 0<BR> strTemp = Left(strTemp,Instr(1,strTemp,"&#039")-1)&_<BR> Right(strTemp,Len(strTemp)-Instr(1,strTemp,"&#039"))<BR> Loop<BR> <BR>&#039Clean out double quotes<BR><BR> Do Until Instr(1,strTemp,Chr(34))= 0<BR> strTemp = Left(strTemp,Instr(1,strTemp,Chr(34))-1)&_<BR> Right(strTemp,Len(strTemp)-Instr(1,strTemp,Chr(34)))<BR> Loop <BR>&#039return the clean string<BR> CleanString = strTemp<BR>End Function<BR><BR>Dim Name, strSQL, dbConnection, cmdTable, rsTable<BR><BR>&#039take the table name from the form and clean it out<BR> Name = CleanString(Request.Form("TableName"))<BR> <BR>&#039Build the store procedure here and clean it out<BR> strSQL = "CREATE TABLE [dbo].[&Name] ( [ID] [int] IDENTITY (1, 1) NOT NULL , [Prefix] [varchar] (250) NULL , [First] [varchar] (250) NULL ) ON [PRIMARY] GO"<BR> strSQL = CleanString(strSQL)<BR> <BR> &#039Set up database connection and command object<BR> <BR>Set dbConnection = Server.CreateObject("ADODB.Connection")<BR>Set cmdTable = Server.CreateObject("ADODB.Command")<BR> dbConnection.Open InitDSN,InitUN,InitPW<BR> cmdTable.ActiveConnection = dbConnection<BR> cmdTable.CommandText = strSQL<BR> cmdTable.CommandType = adCmdStoredProc<BR> &#039Insert new table<BR>Set rsTable = cmdTable.Excute<BR><BR>&#039Close connection<BR>Set cmdTable = Nothing<BR>Set rsTable = Nothing<BR>dbConnection.close<BR>Set dbConnection = Nothing<BR><BR>%&#062; <BR><BR>P.S The SQL string above is just a small part of my big create table procedure.

  2. #2
    John Kim Guest

    Default RE: Please help...ASP and SQL Stored Procedure

    Check the SQL string with VB syntax...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts