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(ByVal 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(sqlAdamUpdate, adamConn)
cmdAdamUpdate.Parameters.Add(NewSystem.Data.SqlCli ent.SqlParameter("@ID",system.Data.SqlDbType.VarCh ar, 10, "ADMAID").Value = SOME THINGI CAN"T FIGURE OUT)
cmdAdamUpdate.Parameters.Add(NewSystem.Data.SqlCli ent.SqlParameter("@PG",System.Data.SqlDbType.VarCh ar, 10, "ADMAPG"))
cmdAdamUpdate.Parameters.Add(NewSystem.Data.SqlCli ent.SqlParameter("@LT",System.Data.SqlDbType.VarCh ar, 10, "ADMALT"))
cmdAdamUpdate.Parameters.Add(NewSystem.Data.SqlCli ent.SqlParameter("@TX",System.Data.SqlDbType.VarCh ar, 10, "ADMATX"))
adamConn.Open()
cmdAdamUpdate.ExecuteNonQuery()
adamConn.Close()
This produces the following error:
System.Web.Services.Protocols.SoapException: Server was unable toprocess request. ---> System.Data.SqlClient.SqlException:Prepared statement '(@ADMAID varchar(10),@ADMAPGvarchar(10),@ADMALT varchar(10),@AD' expects parameter @ADMAID,which was not supplied.
I've Tried this:
Public Function UpdateADMST(ByVal 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.Tables.Add(ADMST)
Dim ID_col As New DataColumn("ADMAID")
adam_UpDS.Tables(0).Columns.Add(ID_col)
Dim PG_col As New DataColumn("ADMAPG")
adam_UpDS.Tables(0).Columns.Add(PG_col)
Dim LT_col As New DataColumn("ADMALT")
adam_UpDS.Tables(0).Columns.Add(LT_col)
Dim TX_col As New DataColumn("ADMATX")
adam_UpDS.Tables(0).Columns.Add(TX_col)
Dim adam_row As DataRow
adam_row = adam_UpDS.Tables(0).NewRow()
adam_row.Item(0) = ID.Substring(0, ID_len)
adam_UpDS.Tables(0).Rows.Add(adam_row)
adam_row.Item(1) = PG.Substring(0, PG_len)
adam_UpDS.Tables(0).Rows.Add(adam_row)
adam_row.Item(2) = LT.Substring(0, LT_len)
adam_UpDS.Tables(0).Rows.Add(adam_row)
adam_row.Item(3) = TX.Substring(0, TX_len)
adam_UpDS.Tables(0).Rows.Add(adam_row)
SqlDataAdapter1.Update(adam_UpDS)
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>