![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2006
Posts: 2
Rep Power: 0
![]() |
CLR-StoreProcdures
Hi
I have a CLR-Stored Procdure I've compiled it and deployed it but it doesn't work. The error message says that Subqueries are not allowed in this context,I wonder if you could help me. by the way I've already reconfigured the Data Base and it's ready to run the CLR-Stored Procdures. here is the code
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void AddGoods(SqlString GoodsID,SqlString TypeName,
SqlString Unit,SqlString GoodsName,SqlString Amount,SqlString Price,
SqlString Description)
{
using ( SqlConnection cnn = new SqlConnection("context connection=true") )
{
SqlCommand cmd = new SqlCommand();
string strType = " (SELECT TypeID FROM Tbl_TypesOfGoods WHERE TypeName='" + TypeName.ToString() + "')";
string strUnit = " (SELECT UnitID FROM Tbl_Units WHERE UnitName='" + Unit.ToString() + "')";
cmd.CommandText = "INSERT INTO Tbl_Goods(GoodsID, TypeID, UnitID, GoodsName, " +
"Amount, Price, Description)" + " VALUES('" + GoodsID.ToString() + "'," +
strType + "," + strUnit + ", '" + GoodsName.ToString() + "', '" +
Amount.ToString() + "', '" + Price.ToString() + "', '" +
Description.ToString() + "');";
cmd.Connection = cnn;
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
}
}
};Thank you |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|