hi thanks for your rep. so how can use datareder to get data from table any examples? waiting for your kind rep.
bapu2889
Posts
-
copy data from 1 table to another table -
copy data from 1 table to another tableDear all, my question sounds very simple and yes it is very simple. what i am looking for just to copy data from one table to another table. i could write insert into table2 ( select * from table1) but in my case there is one database name MyDataBase.mdf and table name Customer so now when user performs year ending (31st march) option then system should create new folder for new year for ex. 2011 if user is working in 2010. so now in folder 2011 i have copy database which is MyDataBase.mdf now i want to copy all the customers from Customer table(in 2010 folder) to Customer table (in 2011 folder) so how can i copy data from same named database and same named table to same named database & table insert into Customer(select * from Customer) So can I differentiate insert Customer and select Customer table? I dont want to change table name in next year. waiting for your kind help.
-
reporting issue in c# applicationok it's done now there is inbult function for this in crystal report ToWord()
-
reporting issue in c# applicationhello i working on my assignment for win form app. there are 2 tables related. and now final part is to create crystal report i have created one report showing bill details it works fine there is no issure. now i want to display amounnt in words so i have created one class and to convert number to words and again it's working fine but i am not storing this amount in words in sql database. so in reporting how can i convert this amount in number into words? is there any way to call my numbertoword class into crystal report? or is there any tool in crystal report to do this? this is my code for loading crystal report
public partial class InvoiceBill : Form { public InvoiceBill() { InitializeComponent(); } public GenerateInvoice invRpt = new GenerateInvoice(); private void InvoiceBill\_Load(object sender, EventArgs e) { sqlDataAdapter1.Fill(invoiceDS1 , "BillDetail"); crystalReportViewer1.ReportSource = invRpt; invRpt.SetDataSource(invoiceDS1); }
waiting for your kind help
-
SQL INSERT ISSUEHELLO SIR THANK YOU VERY MUCH IT'S WORKS NICE NOW I WAS LOOPING IN MY SP AND VB BOTH SO NOW I HAVE MUCH BETTER IDEA ABOUT THIS SO AND I HAVE CONVERTED TO VB. I CAN UNDERSTAND C# BUT I AM NOT VERY GOOD WITH IT BUT ANY WAY YOUR HELP AND UR SUPPORT WAS VERY GOOD THANKS AGAIN :)
-
SQL INSERT ISSUEhello sir thanks for ur rep. and i dont know that i have shouted on any body this is what i have done so far but no luck. this is 2 different sp
ALTER PROCEDURE dbo.NewInsertCommand
(
@City nvarchar(50),
@State nvarchar(50)
)
AS
SET NOCOUNT ON;DECLARE @LocationID int;
INSERT INTO [Location] (City,State)
VALUES (@City, @State)SELECT @LocationID = SCOPE_IDENTITY()
this is the second one
ALTER PROCEDURE dbo.InsertUser
@FirstName varchar(25), @LastName varchar(25), @LocationID int
AS
INSERT INTO \[UserData\] (LocationID, FirstName, LastName)
(SELECT @LocationID, @FirstName, @LastName)
RETURN
and this is the vb
Private Sub AddNewNames()
FirstNameArray.Add(FirstName.Text)
FirstNameArray.ToArray()
LastNameArray.Add(LastName.Text)
LastNameArray.ToArray()
End SubPrivate Sub InsertData()
Try Dim Flag As Boolean = False 'GetDBConnection() Dim cmd As New SqlCommand("NewInsertCommand", LetsGo.GetDBConnection) cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add("@City", SqlDbType.NVarChar).Value = ComboBox1.SelectedItem cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value = ComboBox2.SelectedItem cmd.ExecuteNonQuery() cmd = New SqlCommand("InsertUser", LetsGo.GetDBConnection) cmd.CommandType = CommandType.StoredProcedure For I As Integer = 0 To FirstNameArray.Count - 1 cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = FirstNameArray(I).ToString cmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = LastNameArray(I).ToString cmd.ExecuteNonQuery() Next MsgBox("Data Saved Successfully !", MsgBoxStyle.Information)
and one more thing i dont know how to get @LocationID from one sp to another sp as well so would you mind to guide me please waiting for your kind help thanks
-
SQL INSERT ISSUEHELLO ALL I AM WORKING ON ONE OF MY ASSIGNMENT WITH TWO TABLES AND I HAVE TO USE STORED PROCEDURES BOTH THE TABLES ARE RELATED. LAND PLOT MAY HAVE MORE THEN ONE AQUIRER SO THERE HAS TO BE A PROVISION TO ADD MORE THEN ONE NAMES FOR ONE LAND PLOT SO ONE TABLE IS FOR LAND DETAILS AND SECOND ONE IS FOR CUSTOMER DETAILS THIS IS MY SP
ALTER PROCEDURE dbo.NewInsertCommand
(
@City nvarchar(50),
@State nvarchar(50),
@FirstName nvarchar(25),
@LastName nvarchar(25),
@Count int
)
AS
SET NOCOUNT ON;
DECLARE @LocationID int;
DECLARE @CountB int;
INSERT INTO [Location] (City,State)
VALUES (@City, @State)SELECT @LocationID = SCOPE\_IDENTITY()
SET @CountB = 0
WHILE @CountB < @Count
BEGIN
SET @CountB = @CountB + 1INSERT INTO [UserData] (LocationID, FirstName, LastName)
(SELECT @LocationID, @FirstName, @LastName)
IF @CountB = @Count
BREAK
ENDAND THIS IS MY VB THIS IS FOR TO ADD MULTIPLE NAMES IF THERE IS ANY
Private Sub AddNewNames()
FirstNameArray.Add(FirstName.Text)
FirstNameArray.ToArray()
LastNameArray.Add(LastName.Text)
LastNameArray.ToArray()
End SubTHIS IS FOR TO INSERT DATA
Private Sub InsertData()
Try 'GetDBConnection() Dim cmd As New SqlCommand("NewInsertCommand", LetsGo.GetDBConnection) cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add("@City", SqlDbType.NVarChar).Value = ComboBox1.SelectedItem cmd.Parameters.Add("@State", SqlDbType.NVarChar).Value = ComboBox2.SelectedItem For I As Integer = 0 To CInt(FirstNameArray.Count) - 1 cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = FirstNameArray(I).ToString cmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = LastNameArray(I).ToString Next cmd.Parameters.Add("@Count", SqlDbType.Int).Value = CInt(FirstNameArray.Count) cmd.ExecuteNonQuery() MsgBox("Data Saved Successfully !", MsgBoxStyle.Information) Catch ex As SqlException MessageBox.Show(ex.ToString) Finally FirstNameArray.Clear() LastNameArray.Clear() End
SO IF I ADD ONE NAME THEN IT WORKS JUST FINE BUT IF I ADD MORE THEN ONE THEN I AM GETTING THIS ERROR Argument 'Prompt' cannot be converted to type 'String'. ANY HELP FOR THIS PLEASE
-
sql problemhello thanks for your rep. ok but is this going to loop in sql quary? for adding multiple names this is what i have done
Private Sub GetNewName() AddName.Add(TextBox1.Text) AddName.ToArray() End Sub
so with this i can add one name or 100 names and i have debug this code and it's looks fine but only thing is how can i insert all this name from array to database so in that case i have to loop while i am inserting so this is i have done for insert
Comm = New SqlClient.SqlCommand("InsertNew", LetsGo.AndGetConnection) Comm.CommandType = CommandType.StoredProcedure Comm.CommandText = "InsertNew" Comm.Parameters.Add("@Village", SqlDbType.NVarChar).Value = ComboBox1.SelectedItem.ToString Comm.Parameters.Add("@District", SqlDbType.NVarChar).Value = ComboBox2.SelectedItem.ToString For I As Integer = 0 To AddName.Count Comm.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = AddName(I) Next Comm.ExecuteNonQuery() Conn.Close() MsgBox("Item Saved")
and it looping through all the name i have entered but at last it shows error error "Index was out of range. must be non-negative and less then the size of the collection parameter name index" waiting for your kind help
-
sql problemhello all i am working on one of my assignment about sql win app. with stored procedure.and there is two different tables with ralation to PlotID so it's working fine. now only problem is this application must have functionality to add multiple customer names with related land plot. At the moment i can add one name and one land plot i mean if i add some details about land plot and name of customer then it works fine but now i need to create functionality to add multiple customer name with same land plot bueause one land plot may have multiple owners. this is my insert sp so one of my friend said you can use multiple parameters to add multiple names but what if i need to add 3 or 4 names so this is what i have done according to my friend and this is also working fine.
ALTER PROCEDURE dbo.InsertNew
(
@FirstName nvarchar(25),
@LastName nvarchar(25),
@FirstName2 nvarchar(25),
@LastName2 nvarchar(25),
@Village nvarchar(25),
@District nvarchar(25)
)
AS
SET NOCOUNT ON;
DECLARE @PlotID intINSERT INTO PlotDetails (Village,District)
VALUES (@Village, @District)
SELECT @PlotID=SCOPE\_IDENTITY()
INSERT INTO CustomerDetails ([FirstName], [LastName],[PlotID])
(SELECT @FirstName, @LastName, @PlotID)
UNION ALL
(SELECT @FirstName2, @LastName2, @PlotID)RETURN
and this is vb for insert record
Private Sub InsertNew()
Try
Comm = New SqlClient.SqlCommand("InsertNew", LetsGo.AndGetConnection)
Comm.CommandType = CommandType.StoredProcedure
Comm.CommandText = "InsertNew"Comm.Parameters.Add("@Village", SqlDbType.NVarChar).Value = ComboBox1.SelectedItem.ToString Comm.Parameters.Add("@District", SqlDbType.NVarChar).Value = ComboBox2.SelectedItem.ToString Comm.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = TextBox1.Text Comm.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = TextBox2.Text Comm.Parameters.Add("@FirstName2", SqlDbType.NVarChar).Value = FirstName2.Text Comm.Parameters.Add("@LastName2", SqlDbType.NVarChar).Value = LastName2.Text Comm.ExecuteNonQuery() Conn.Close() MsgBox("Item Saved") Catch ex As Exception MsgBox(ex.Message) End Try End Sub
so is there any other way to do this i mean loop in sql? waiting for your kind help thanks
-
database relationship problemhello I am working on one win app with sql database visual basic i have created 4 tables singlecustomer, jointcustomer, address and plotdetais. I have created relationship with all 4 tables singlecustomer with address and plotdetails second jointcustomer with address and plotdetails and then I have also created database diagram and it show all the relationships now when i drag and drop sql adapter to configure it database relationship dosent look right in query builder it's not showing correct relationship with all tables. in query builder when i add tables first time it's different relationship and then i canceled it and add tables second time with different order so it shows different relationship waiting for your kind help thanks
-
data problemhello sir yes it's done now thanks for your kind help thanks again
-
data problemhello sir thanks for your rep. as you mentioned but i dont know how to do it so could you please tell me how to do it waiting for your kind help thanks
-
data problemhello i am new to this and i am doing my assignment with vs2003. I need to create simple one page web project in vs2003 with one datagrid so I connect to northwind database in server ex. in vs 2003 and then drag a datagrid and then genereate dataset and configure dataset with database but when i run the project it gives me error Server Error in '/WebApplication3' Application. -------------------------------------------------------------------------------- The SELECT permission was denied on the object 'Employees', database 'Northwind', schema 'dbo'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: The SELECT permission was denied on the object 'Employees', database 'Northwind', schema 'dbo'. Source Error: Line 192: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Line 193: 'Put user code to initialize the page here Line 194: SqlDataAdapter1.Fill(DataSet11) Line 195: Line 196: End Sub Source File: c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb Line: 194 Stack Trace: [SqlException: The SELECT permission was denied on the object 'Employees', database 'Northwind', schema 'dbo'.] System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) WebApplication3.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb:194 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain() -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.1.4322.2443; ASP.NET Version:1.1.4322.2443
-
problem creating asp.net project in visual studio 2003 with xp prohello sir thanks for your prompt response currently i have one small assignment to create web project with one page so it should display author table from pubs database into datagrid thats all so what i have done drag and drop sql data adapter on the web page and went through wizard to complite but at the end of wizard it shows generated error for update, delete and cancle so i dont know what to do with this and when i try to run the project it shows loging error but if i right click on sql data adapter and select priview data it shows all the data waiting for your kind help have a nice time
-
problem creating asp.net project in visual studio 2003 with xp proHello sir thanks for your rep. but i dont know how to do it i am still searching on net waiting for your kind rep. thanks
-
problem creating asp.net project in visual studio 2003 with xp prohello i am new to asp.net i have created on small web project with one datagrid on page and when i drag and drop sql data adapter on page it shows error "Generated SELECT Statment" and then i have managed to solve this issue but now it showing "Generated CANCEL Statment" "Generated UPDATE Statment" "Generated DELETE Statment" so i dont know what to do now so I have tried to run the project but it also showing error Server Error in '/WebApplication3' Application. -------------------------------------------------------------------------------- Login failed for user 'MACHINE NAME\ASPNET'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Login failed for use MACHINE NAME\ASPNET'. Source Error: Line 59: 'Put user code to initialize the page here Line 60: If Not Page.IsPostBack Then Line 61: SqlDataAdapter1.Fill(DataSet11) Line 62: DataBind() Line 63: Source File: c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb Line: 61 Stack Trace: [SqlException: Login failed for user 'DEEPAK-5WT558AI\ASPNET'.] System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474 System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372 System.Data.SqlClient.SqlConnection.Open() +384 System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44 System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38 WebApplication3.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb:61 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain() -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.1.4322.2443; ASP.NET Version:1.1.4322.2
-
Displaying Image in ASP.NET AJEXThanks for your rep. but still I am not getting any ware as i dont know JS i copy and past between code but there are blue lines and i my assignment is asp.net using visual basic waiting for your kind rep. have a nice day
-
Displaying Image in ASP.NET AJEXHello sir Thanks for your rep. sir I dont know JS and C# so any other help I have tried to change this to vb but i am bit strugling with 2 things 1- setInterval(changeImage, 250); 2- img.src = waiting for your kind rep. thanks
-
Displaying Image in ASP.NET AJEXHello all I am working on my one of my assignment to create ASP.NET AJAX project it's simple with one default.aspx page and on the middle of page there is one updatepanel and inside UpdatePanel there is on ImageBox and one Timer I have one Image folder and there are 16 images and i want to display image in to imagebox in order from 1 to 16 and after 16th image it goes to image 1 and so on this is what i have done so far and it's working ok but still i want to do some thing in it
Dim MyImage(15) As String Private Sub GetImages() MyImage(0) = "1.png" MyImage(1) = "2.png" MyImage(2) = "3.png" MyImage(3) = "4.png" MyImage(4) = "5.png" MyImage(5) = "6.png" MyImage(6) = "7.png" MyImage(7) = "8.png" MyImage(8) = "9.png" MyImage(9) = "10.png" MyImage(10) = "11.png" MyImage(11) = "12.png" MyImage(12) = "13.png" MyImage(13) = "14.png" MyImage(14) = "15.png" MyImage(15) = "16.png" End Sub Sub GetNextImage(ByVal Src As Object, ByVal Args As EventArgs) 'Retrieve the array from view state MyImage = ViewState("PictureArray") 'Increment the image counter ViewState("Counter") += 1 If ViewState("Counter") > 15 Then ViewState("Counter") = 0 End If 'Assign the next image to the control BannerImage.ImageUrl = MyImage(ViewState("Counter")) End Sub Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then '--Load as array with image ursl and save to view state Call GetImages() ViewState("PictureArray") = MyImage '--Establish a counter to keep track of the array index ViewState("Counter") = 0 BannerImage.ImageUrl = MyImage(ViewState("Counter")) End If End Sub
and HTML is like <asp:UpdatePanel ID="BannerUpdatePanel" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer2" /> </Triggers> <ContentTemplate> <asp:Timer ID="Timer2" runat="server" Interval="250" OnTick="GetNextImage"> </asp:Timer> <br /> <asp:Image ID="BannerImage" runat="server" ImageUrl="~/G
-
image loop in vb.nethello thanks for your rep. yes it's works fine this is what i changed
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'PictureBox1.Image = (MyImage(I)) Static nextImage As Integer = 0 PictureBox1.Image = MyImage(nextImage) nextImage = (nextImage + 1) Mod MyImage.Length End Sub
it's working as i was trying to thanks a lot sir have a nice day :-D