Hi all,
Simple question concerning infopath, webservice, and an INSERTINTO Sql command:
WARNING: All following content is NEWBIE generated and froughtwith errors (probably)
All I want to do is add a 4 column row to a SQL Server tableusing infopath, a webservice, and ADO.net.
I've tried this:
Public Function UpdateADMST(ByV al ID As String, ByVal PG AsString, ByVal LT As String, ByVal TX As String) As DataSet
Dim sqlAdamUpdate As String = "INSERT INTO ADMST (ADMAID, ADMAPG,ADMALT, ADMATX) VALUES(@ID, @PG, @LT, @TX)"
Dim cmdAdamUpdate As New SqlCommand(sqlA damUpdate, adamConn)
cmdAdamUpdate.P arameters.Add(N ewSystem.Data.S qlClient.SqlPar ameter("@ID",sy stem.Data.SqlDb Type.VarChar, 10, "ADMAID").V alue = SOME THINGI CAN"T FIGURE OUT)
cmdAdamUpdate.P arameters.Add(N ewSystem.Data.S qlClient.SqlPar ameter("@PG",Sy stem.Data.SqlDb Type.VarChar, 10, "ADMAPG"))
cmdAdamUpdate.P arameters.Add(N ewSystem.Data.S qlClient.SqlPar ameter("@LT",Sy stem.Data.SqlDb Type.VarChar, 10, "ADMALT"))
cmdAdamUpdate.P arameters.Add(N ewSystem.Data.S qlClient.SqlPar ameter("@TX",Sy stem.Data.SqlDb Type.VarChar, 10, "ADMATX"))
adamConn.Open()
cmdAdamUpdate.E xecuteNonQuery( )
adamConn.Close( )
This produces the following error:
System.Web.Serv ices.Protocols. SoapException: Server was unable toprocess request. ---> System.Data.Sql Client.SqlExcep tion:Prepared statement '(@ADMAID varchar(10),@AD MAPGvarchar(10) ,@ADMALT varchar(10),@AD ' expects parameter @ADMAID,which was not supplied.
I've Tried this:
Public Function UpdateADMST(ByV al ID As String, ByVal PG AsString, ByVal LT As String, ByVal TX As String) As DataSet
Dim ID_len As Integer = ID.Length
Dim PG_len As Integer = PG.Length
Dim LT_len As Integer = LT.Length
Dim TX_len As Integer = TX.Length
Dim adam_UpDS As New DataSet
Dim ADMST As New DataTable
adam_UpDS.Table s.Add(ADMST)
Dim ID_col As New DataColumn("ADM AID")
adam_UpDS.Table s(0).Columns.Ad d(ID_col)
Dim PG_col As New DataColumn("ADM APG")
adam_UpDS.Table s(0).Columns.Ad d(PG_col)
Dim LT_col As New DataColumn("ADM ALT")
adam_UpDS.Table s(0).Columns.Ad d(LT_col)
Dim TX_col As New DataColumn("ADM ATX")
adam_UpDS.Table s(0).Columns.Ad d(TX_col)
Dim adam_row As DataRow
adam_row = adam_UpDS.Table s(0).NewRow()
adam_row.Item(0 ) = ID.Substring(0, ID_len)
adam_UpDS.Table s(0).Rows.Add(a dam_row)
adam_row.Item(1 ) = PG.Substring(0, PG_len)
adam_UpDS.Table s(0).Rows.Add(a dam_row)
adam_row.Item(2 ) = LT.Substring(0, LT_len)
adam_UpDS.Table s(0).Rows.Add(a dam_row)
adam_row.Item(3 ) = TX.Substring(0, TX_len)
adam_UpDS.Table s(0).Rows.Add(a dam_row)
SqlDataAdapter1 .Update(adam_Up DS)
Which gives a "narrowing conversion" error.
This CANNOT be that difficult, but do you think I can find anexample anywhere??? Nope. Nope, and Nope.
Any help would be great.
Insanely Yours,
ed
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>NcPnbFY0jE+ 2oDonb4aIAg==</Id>