Hi All
I want to insert the listbox items in the database table using a Stored procedure.
Any help will be useful
Thanks!!!!!!!1
Hi All
I want to insert the listbox items in the database table using a Stored procedure.
Any help will be useful
Thanks!!!!!!!1
ListBox Control
Douglas R
Hi
Thanks for replying, but I want to do it using a Stored Proc.
But I am not able to do it, as the data type of var0 and var1 is int and from here it is picking up string, and it just picks up the 1st value from the listbox
Dim attr0param, attr1param As SqlParameter
Dim objCmd As New SqlCommand
objConn.Open()
objCmd.Connection = objConn
objCmd.CommandType = CommandType.StoredProcedure
objCmd.CommandText = "s_Proc"
Dim i As Integer
For i= 0 To lbNames.Items.Count - 1attr0param = objCmd.Parameters.Add("@var0", SqlDbType.int)
attr0param.Direction = ParameterDirection.Input
attr0param.Value = listbox1.Items(i).Value
attr1param = objCmd.Parameters.Add("@var1", SqlDbType.int) attr1param.Direction = ParameterDirection.Input attr1param.Value = listbox1.Items(i+ 1).Value Nextand StoredProc is
Create Procedure dbo.s_Proc
@var0 int=null,
@var1 int=null,
As
Insert vendorAttributes
(
CreateDate,
ModDate,
CreateUser,
ModUser,
var0,
var1,
)
Select
attrCreateDate,
attrModDate,
attrCreateUser,
attrModUser,
@var0,
@var1,
from Table1
Sean Shanny
DataSet
ds = new DataSet (); DataTable dt = ds.Tables.Add ( "Table1" );dt.Columns.Add (
"ListValue", typeof ( String ) ); foreach ( Object obj in listBox1.Items ){
DataRow dr = dt.NewRow ();dr[
"ListValue"] = obj.ToString ();}
SqlConnection connection = new SqlConnection ( @"DataSource=.\sqlexpress; Initial Catelog=Database1; User Id= sa; Password=sa;" ); SqlDataAdapter da = new SqlDataAdapter ( "Select ListValue From Table1", connection ); SqlCommandBuilder cb = new SqlCommandBuilder ( da );da.Update ( dt );
Pete_M
grellsworth
Use the Convert.ToInt32() method.