|
are you getting any compile time error?
Best Regards,
Apurva Kaushal
|
|
|
|
|
No I am getting runtime error saying :
"The name 'ArrayList' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted."
I dont know what is the problem????
Thanks and regards.
|
|
|
|
|
you try like this:
for(int cntRow = 0; cntRow < dt.Rows.Count ; cntRow++)<br />
{<br />
for(int cntCol = 0; cntCol < dt.Columns.Count ; cntCol++)<br />
{<br />
string str = dt.Rows[cntRow][cntCol].ToString();<br />
arrDataGriditems.Add(dt.Rows[cntRow][cntCol]);<br />
<br />
<br />
<br />
}<br />
}<br />
cchecklist.CheckListInsert=arrDataGriditems;
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
////fill arraylist
sub fill_Array()
Dim gridItem As DataGridItem
Dim idArray As New ArrayList()
For Each gridItem In DataGrid1.Items
Dim lbl As Label = DirectCast(gridItem.FindControl("ID"), Label)
idArray.Add(lbl.Text)
next
end sub
///saving to database
Sub Save()
for i=0 to DataGrid1.Items.Count-1
sql="insert into tablename name="+idarray(i)
//Execute this query
next
end sub
If it's not of you mean......have some more discussion
Regards,
Nagraj
|
|
|
|
|
Tell me why are we using Label here???I understood the code but not the Label one.
I am not getting datagriditem().It contains some arguments.I am using C#.Net
-- modified at 6:33 Tuesday 20th June, 2006
|
|
|
|
|
Hi,
Ok I think you don't need arraylist for your purpose.
See This also works.
///saving to database
Sub Save()
for i=0 to DataGrid1.Items.Count-1
sql="insert into tablename name="+DataGrid1.Items(i)
//Execute this query
next
end sub
|
|
|
|
|
I dont want to write my Query on Form itself.I need to write it in Class File.Also I need see for Transaction management.
Please help how do I save it(DataGrid) into an Arraylist as I have to define Arraylist Property and everything will be take care by it.
I just need to save all the records in Arraylist and finally call a function which is inside the class file and inside this function I write Insert query which will have arraylist as one of the parameter.
I hope u got my problem.
Thanks and regards.
|
|
|
|
|
This is what I want you to specify.
Means You are using procedure to save in database which is located in some class and you want to send datagrid records to this procedure.
I hope I am clear now...
Now instead of using arraylist use one class having property within it.
ex.
public class class1
Private _id As Integer = 0
Private _degreeName As String = ""
Public Property ID() As Integer
Get
Return _id
End Get
Set(ByVal Value As Integer)
_id = Value
End Set
End Property
Public Property DegreeName() As String
Get
Return _degreeName
End Get
Set(ByVal Value As String)
_degreeName = Value
End Set
End Property
end class
Now in your webpage code
dim myclass as new class1
for i=0 datagrid1.items.count-1
// set attribute values
with myclass
.id=DataGrid1.Items(i).Cells(0).Text
.degreeName=DataGrid1.Items(i).Cells(1).Text
end with
saveclass.Save_record(myclass) //call saving routine from another class i.e saveclass
next
///saving procedure
public sub Save_record(byval _myclass as myclass)
sql="insert into tablename values (" + _myclass.id +","+_myclass.degreename +")"
///Execute sql code here
end sub
I added two new things
1)Add new class i.e. class1 for storing value
2)pass this class1's object as parameter to record saving procedure
Please check for syntax I just put idea for you.And I sure this will work
Thanks,
Nagraj
|
|
|
|
|
Can u please tell me the syntax of class in C#.NET.
I came to know what actually u r doing but since I dont know VB or VB.NET therefore some of the code I am not getting.
Thanks and Regards.
|
|
|
|
|
Ya I have tried like this and keeping cchecklist.CheckListInsert=arrDataGriditems; inside 1st for loop also I have tried but same error.
|
|
|
|
|
dont put that inside first loop put that outside the loop and then try.
Best Regards,
Apurva Kaushal
|
|
|
|
|
I have tried with both ways but its not working...
|
|
|
|
|
probably i am not exactly understanding but the same is working for me. I have created a arraylist property and assigning the arraylist object to it and its giving me the correct result.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
I have created Arraylist of Arraylist and then assign it.Following is the code:
ArrayList checkList = new ArrayList();
ArrayList row = new ArrayList();
for(int cntRow = 0; cntRow < dt.Rows.Count ; cntRow++)
{
for(int cntCol = 0; cntCol < dt.Columns.Count ; cntCol++)
{
row.Add(dt.Rows[cntRow][cntCol]);
}
checkList.Add(row);
}
cchecklist.CheckListInsert = checkList;
result = cchecklist.InsertChecklist();
Line number 12 is call of Insert Function which I have written in class file and the code for insertion is the following:
int checklistno = 0;
for(int cnt = 0; cnt < checklistInsert.Count; cnt++)
{
ArrayList row = (ArrayList) checklistInsert[cnt];
checklistno++;
string sql = "INSERT INTO checklist "
+ " values(" + scheduleno + ", " + checklistno + ",'" + row[1] + "', "
+ " '" + row[2] + "','" + row[3] + "', '" + row[4] + "' , '" + status + "' ,"
+ " '" + histo + "' , '" + CDate + "' , " + CUser + " ,"
+ " '" + MDate + "', " + MUser + " )";
result = con.ExecuteNonQuery(sql);
}
if(result == 1)
{
con.CommitTrans();
}
Still its not working.It inserts the first record two times and second record is not consider.
If any changes in the code then please let me know.
Thanks and Regards.
|
|
|
|
|
Hi,
the code is working fine for me, only thing is i have assigned the datatable with some of my data and the rest of code is working here. I am getting the correct value of row1[1], row1[2], row1[3]...
Best Regards,
Apurva Kaushal
|
|
|
|
|
Can u please Copy paste that code for me???
Thanks and regards
|
|
|
|
|
Hi all,
I am creating query at runtime this query is depend upon dynamic criteria selection.
Now when this query is created I want to send this as stored procedure query part in sql stored procedure
i.e.
select * from records where recno>100 // this is sql query
I want to set this query as stored procedure query
//stored procedure
create procedure recordcount
as
//above generated query shoul be here
return
I hope you understand my problem.
If Know solution share with me......
Let's Teach Life To Laugh........
|
|
|
|
|
CREATE PROCEDURE recordcount<br />
@recno int(4)<br />
AS<br />
SELECT * from records where recno > 100
|
|
|
|
|
Hi,
You don't get me.
Basically I want to send my dynamic query as query to stored procedure.I mean stored procedure is not created i want to create it dynamically with my dynamic query
|
|
|
|
|
Please specify your problem clearly
|
|
|
|
|
hi try it
bteeeeeeeeeeeee
create procedure getrecno
@recno
as
begin
select * from tablename recno>=100
end;P
suresh babu.k
-- modified at 10:33 Tuesday 20th June, 2006
|
|
|
|
|
I want to generate report in asp DOT Net(vb) using CrystalReport. So pls tell me the procedure(steps) to do the reporting.
thanks in advance
|
|
|
|
|
Hi,
Please follow,
1)Drag and drop crystalreportviewer control on form
2)Right click on project in solution window
add new item - select Crystalreport
3) design your report and save it i.e. report1
4)right click on crystalreportviewer and select property
5) In property window ReportSource Select your crystalreport report1
I hope this help you.
Regards,
Nagraj
Let's Teach Life To Laugh........
|
|
|
|
|
|
I am facing a problem in Publishing my Website. I have created a website to experiment with the VS 2005 Login control. My website is working fine in Visual Studio 2005. But when I publish it and run it through IIS, this login control fails to work (not letting any user to log on). I guess there is some problem in Database connection. Website is using MS SQL 2005 for Membership Provider.
Please let me know if you know the solution.
Adarsh
|
|
|
|