For insert new entry...I used dataset and first all entry in dataset then i insert this dataset into datatabel of database.
For update edit entry....First i bind tabel to dataset then i update,delete in dataset then i insert dataset to database then there are problem that is there are once again entry of dataset to that tabel.
I also solved this problem by delete record which bind to dataset on save(insert )data set to database and then again insert dataset to tabel and solve it.
Hi I have to populate some datas from sql server database and display it directly in a CSV Format or CSV file. When i run the project it should provide me an option to whether open or save or cancel the file. when i click open it should be opened and be viewed in a excel sheet in CSV format and when i click save it should ask the destination folder and should be saved there in CSV format and when i click cancel it should be cancelled and the application should be closed. pls note that all these actions should happen in the same browser and should not be redirected to anyother page. Can anybody give me the detailed description and code in Asp.Net using C# .It's very Urgent. RegardsVijay.
Hi! I'm a novice in asp .net I've a SqlDataSource component on an Aspx page.In the associated C# file, I would like to use datas from the query stored in the SqlDataSource component.How to do this? Thanxs :)
I am a student in a compagny because it´s my training. But, I must use MS SQL server and i don´t know at all this software ! I must import datas , which are in a ascii form, into MS SQL serveur 7,0.
Can you give me further information please, because it´s not easy at all ! thanks
i want to get some results but only for one month. like that;
select * from News where PubDate = month(9)
i tried use between dates but i got errors because all of months aren't 30 or 31 days ... For example February is 28 days sometime.. So how can i get a month results...
Hello, i am using sql server ce 2.0 for my device application.but this database sometimes gets corrupt,and i am not working with big size datas,if sdf file's size grow up,sdf file's performance gets knock out. for example: work with 50 mb data..what can i do?please somebody help me ?
I am having a problem to get all datas into one table I must get datas from 2 other tables datas from the first table are columns but datas of the second table are rows
I cannot change the structure of TableA because an other application is using it as it is
TableA num | value | key 1 | a | 1400 2 | b | 1401 3 | c | 1402 4 | d | 1403 ...|... | 1403
TableB key | name | descr | value 400 | john | ok | 451
TableC (the table where I want to insert datas from Table1 and Table2)
val1 | val2 | val3 | val4 |name | descr | value 1 | 2 | 3 |4 | john | ok | 451
TableA has thousands of rows and different numbers I must get 8 different datas from TableA
so I get an horrible Query !
SELECT
TableB.name, TableB.descr, TableB.value, TableA_1.value AS val1, TableA_2.value AS val2, TableA_3.value AS val3, TableA_4.value AS val4, TableA_5.value AS val5, TableA_6.value AS val6, TableA_7.value AS val7, TableA_8.value AS val8
FROM dbo.TableB INNER JOIN dbo.TableA_1 ON TableB.key = TableA_1.key INNER JOIN dbo.TableA_2 ON TableB.key = TableA_2.key INNER JOIN dbo.TableA_3 ON TableB.key = TableA_3.key INNER JOIN dbo.TableA_4 ON TableB.key = TableA_4.key INNER JOIN dbo.TableA_5 ON TableB.key = TableA_5.key INNER JOIN dbo.TableA_6 ON TableB.key = TableA_6.key INNER JOIN dbo.TableA_7 ON TableB.key = TableA_7.key INNER JOIN dbo.TableA_8 ON TableB.key = TableA_8.key
WHERE TableA_1.num = 145 AND TableA_2.num = 80 AND TableA_3.num = 3160 AND TableA_4.num = 41 AND TableA_5.num = 50 AND TableA_6.num = 51 AND TableA_7.num = 53 AND TableA_8.num = 56
Hi guys,I have a problem with my query. What i want to happen is to populate my table EV_NOTIFICATIONDETAILS (Docownerid, CurrentSentDate, LastSentDate, detailsID, GeneralRemarks) using the datas from the two different tables EV_NOTIFICATIONHEADER and EV_DOCDETAILS.I tried to create some a query but im having a error. The problem is once i insert the data from datas to the columns Docownerid, CurrentSentDate, LastSentDate the datas are stored in the database and when i tried to insert the remaining columns TO EV_NOTIFICATIONDETAILS detailsID, GeneralRemarks getting the datas from EV_DOCDETAIL it creates a new set of records in the database. Meaning it doesn't update the records in the table EV_NOTIFICATIONDETAILS but it creates a new set of records.here's my code:INSERT INTO EV_NOTIFICATIONDETAILS (Docownerid, CurrentNoticeSentDate, LastNoticeSentDate) SELECTDocownerid, CurrentSentDate, LastSentDateFROMEV_NOTIFICATIONHEADERINSERT INTO EV_NOTIFICATIONDETAILS (detailsID,GeneralRemarks) SELECTdetailsID,GeneralRemarksFROMEV_DOCDETAIL Any ideas and suggestions will be greatly appreciated.
I have a report in reporting services which has use many datasets. Those datasets retrieve data from a same table.
Each Dataset use a store procedure.
In the first store procedure (associated to the first dataset), i call an another store procedure which fill the table.
My problem is that datasets haven't datas retrieved in the order of their position. So the third (for exemple) can begin retrieve data while the first store proc (called in the first dataset) is still running. I had logging start/finish time of each SP and it appears that Dataset are retrieved in an asynchronous way.
Does anyone face the same problème. Is there a solution to execute an store procedure before retrieving data ?
I have a web form with a text field that needs to take in as much as the user decides to type and insert it into an nvarchar(max) field in the database behind. I've tried using the new .write() method in my update statement, but it cuts off the text after a while. Is there a way to insert/update in SQL 2005 this without resorting to Bulk Insert? It bloats the transaction log and turning the logging off requires a call to sp_dboptions (or a straight-up ALTER DATABASE), which I'd like to avoid if I can.
I actually work in an organisation and we have to find a solution about the data consistancy in the database. our partners use to send details to the organisation and inserted directly in the database, so we want to create a new database as a buffer database to insert informations from the partners then make an update to the main database. is there a better solution instead of that?
I am using two database server. Both are sql server.Â
My task is :I want to insert data from server 1 table to server 2 table and update same when modified the existing data from server 1. is it possible to do the integration in single package.
I know to do insert and update seperately by ssis but need to do same with single task.Â
I have two SQL Express database and I want to do two things. One is to transfer a table over to the other database. Two, move the files from one table in one database to another. Please let me know when you get a chance.
I was able to connect to the SQL Database Pension with table clients with table values: ID, State, Name.'Create(connection)Dim conn As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)'open connectionconn.Open()However, I'm not sure how to insert a new row with an incremental ID number and a new State and Name.Sorry, I'm really new with VWD.
I have two sql servers one is Nt server another one is Nt workstation,i am able to admin from both sides.but i don't know how to insert/update one database table to another database table, pls. give me some ideas for this.
We have different databases on the same server: Whrs001, Whrs002, etc. All databases have the same structure.
Suppose i have a table "location" create table location ( location_id int not null primary key, location_name varchar(50) not null )
I need to inserts data in "location" tables of different databases. But these inserts needs to be across databases. For example from the "Whrs003" database I need to insert data (location_id=123, location_name='markham') in "location" table of "Whrs001" database.
So my thinking is to defined a stored proc which has database name as an argument: create procedure location_insert @a_database_name varchar(100), @a_location_id int, @a_location_name varchar(50) as ...
So for the above example the call will be : exec location_insert 'Whrs001', 123, 'markham'
What would be the actual insert statement in this case? And what things i neeed to take care fo to make sure it always execute successfully?
Insert into excelb.B.dbo.Emp(Employee_Name,Emp_addr) Values (@Employee_Name,@Emp_Addr) select * from excelb.A.dbo.Emp
excelb - server name
now my problem is a server to another server insert the data that not acces the data and i am using different password the servers- but same pasword are insert the data
I'm not sure what the problem is. I am not getting any errors, but I can't get this code to insert into my SQL db. I've checked the permissions on the database and table, and it looks fine. Is there something wrong with this code? I'm trying to switch from VB to C#, so it's still new to me. I've used the connection string in another APP so I know it works. If I'm not getting an asp.net error, does that point to a problem with the DB? Thanks. protected void Button1_Click(object sender, EventArgs e) { SqlConnection Conn;SqlCommand Command; Conn = new SqlConnection();Conn.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];Command = new SqlCommand(); Command.CommandText = "INSERT INTO [tbl_Test] ([test_name], [test_email]) VALUES (@test_name, @test_email)"; Command.CommandType = CommandType.Text;Command.Connection = Conn;Command.Parameters.Add("test_name", tbName.Text);Command.Parameters.Add("test_email", tbEmail.Text); try { Command.Connection.Open();Command.ExecuteNonQuery(); } catch (Exception ex) { lError.Text = ex.Message; } finally { Command.Connection.Close();pSubscribe.Visible = false;lThanks.Visible = true; }
Hi, I am getting xml data from a webservice.. and in that xml data there in field called State but on the system that we are getting the data from has a text box where the user can enter NC or North carolina.. But our system is set up to just accept a two letter character. like NC.. So suppose if the user sends North carolina instead of NC the nothing takes places on our system cause we get an error saying that Two many characters..
SO i am looking for ideas that will solve this problem but have the state column accept just 2 letters any help will be appreciated KAren
My problem is that when I add a question and the question contains a ' (For instance: I'm going to the store), an error message shows up for 'm from I'm. Here is my code. SqlConnection myConnection = new SqlConnection("Server=???;Database=???;Persist Security Info=True;User ID=???;Password=???"); SqlCommand insertCmd = new SqlCommand(); insertCmd.CommandType = System.Data.CommandType.Text; insertCmd.CommandText = "INSERT INTO TestQuestions (unitChapterID, question, answerA, answerB, answerC, answerD, answer) VALUES (" + int.Parse(DropDownList3.Text.ToString()) + ", '" + questionAddBox.Text.ToString() + "', '" + aAddBox.Text.ToString() + "', '" + bAddBox.Text.ToString() + "', '" + cAddBox.Text.ToString() + "', '" + dAddBox.Text.ToString() + "', '" + answerAddBox.Text.ToString() + "')"; insertCmd.Connection = myConnection; myConnection.Open(); insertCmd.ExecuteNonQuery(); myConnection.Close();
I Have an error: Server Error in '/quanlythietbi' Application. INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_yeucau_nhanvien'. The conflict occurred in database 'equipment', table 'nhanvien', column 'manv'. The statement has been terminated. Source Error: Line 129:mycommand.Parameters.Add(new SqlParameter("@noidung_yc1",System.Data.SqlDbType.Text)); Line 130:mycommand.Parameters["@noidung_yc1"].Value = TextBox1.Text; Line 131:int i = mycommand.ExecuteNonQuery(); Line 132:if (i>0) Line 133:{and this is my code:string sqlstring = "Select * from yeucau where ngayGiaiQuyetxong='"+ Label8.Text +"' and date_yc='" + Label7.Text + "' and manv_yc='"+ TextBox2.Text + "' and noidung_yc='"+ TextBox1.Text+ "'";myconnection = new SqlConnection(stringconn);mycommand = new SqlCommand(sqlstring,myconnection);myconnection.Close();myconnection.Open();mycommand = new SqlCommand(insertquery,myconnection); mycommand.Parameters.Add(new SqlParameter("@ngayGiaiQuyetxong1",System.Data.SqlDbType.Char,10));mycommand.Parameters["@ngayGiaiQuyetxong1"].Value = Label8.Text;mycommand.Parameters.Add(new SqlParameter("@date_yc1",System.Data.SqlDbType.SmallDateTime));mycommand.Parameters["@date_yc1"].Value = Label7.Text;mycommand.Parameters.Add("@manv_yc1",System.Data.SqlDbType.Char,10);mycommand.Parameters["@manv_yc1"].Value = TextBox2.Text;mycommand.Parameters.Add(new SqlParameter("@noidung_yc1",System.Data.SqlDbType.Text));mycommand.Parameters["@noidung_yc1"].Value = TextBox1.Text;int i = mycommand.ExecuteNonQuery();if (i>0){lbcheck.Text = "Ä?ã Cáºp Nháºt Yêu Cầu.";} --------------------------------------------------------------------------------------------------------------------------------I don't know what I must do to repair it :(
What is wrong with this code the dropdowlist mainlyusing System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class NewAccount : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void NaccountButton_Click(object sender, EventArgs e) { if (Page.IsValid) { //Define data objects SqlConnection conn; SqlCommand comm; //read from web config string connectionString = ConfigurationManager.ConnectionStrings["OneBank"].ConnectionString; //Initialize connection conn = new SqlConnection(connectionString); //create command comm =new SqlCommand( "INSERT INTO Customer (FirstName, LastName, Street, City, State," + "Zip, Phone, Payee,AccountType)" + "VALUES(FirstName, LastName, Street, City," + "State, Zip, Phone, Payee,AccountType)", conn); //add parameters comm.Parameters.Add("@FirstName", System.Data.SqlDbType.NVarChar, 50); comm.Parameters["@FirstName"].Value=Firstname.Text; comm.Parameters.Add("@LastName", System.Data.SqlDbType.NVarChar, 50); comm.Parameters["@LastName"].Value=lastname.Text; comm.Parameters.Add("@Street", System.Data.SqlDbType.NVarChar, 50); comm.Parameters["@Street"].Value=street.Text; comm.Parameters.Add("@City", System.Data.SqlDbType.NVarChar, 50); comm.Parameters["@City"].Value=city.Text; comm.Parameters.Add("@State", System.Data.SqlDbType.NVarChar, 50); comm.Parameters["@State"].Value=state.Text; comm.Parameters.Add("@Phone", System.Data.SqlDbType.Int); comm.Parameters["@Phone"].Value=phone.Text; comm.Parameters.Add("@AccountType", System.Data.SqlDbType.NVarChar, 50); comm.Parameters["AccountType"].Value = dropdownlist1.SelectedValue.ToString(); //Enclose database in try catc finally try { //open connection conn.Open(); //execute the command comm.ExecuteNonQuery(); //reload query Response.Redirect("NewAccount.aspx"); } catch { //Display error Errormessage.Text= "Error submitting request!"; } finally { conn.Close(); } } }}
This is the table where thisis going customer ------------- customerID pk generated automatically firtsname lastname street city statezipphoneaccountType
I am creating a zipcode search radius function for my site, and I downloaded a .sql file containing the info I need. The problem is that on the latitude and longitude colunm it needs to be entered with a decimal such as 73.5598. If the column type is Decimal I can manually enter it, but when it's inserted via the script it rounds the number ie. 73 The only type I can get to accept the .sql script as is, is nvarchar, but then it has trouble converting to a numeric for the radius. This is the script I am entering: INSERT INTO classifieds_ZipCodes (zip, city, state, state_name, longitude, latitude, rlong, rlat) VALUES ('00501', 'HOLTSVILLE', 'NY', 'New York', '73.0456', '40.8153', '1.27479232112', '0.712308900524') Any ideas?? Keep in mind there are over 42,000 zipcode entries Thank you Daniel Meis
I have a page with over 20 Textbox and DDL controls and an upload in various Divs and Panels (Ajax enabled) that are used for gathering user data. Some of the fields are mandatory and some optional. In the Code behind (VB- I am a complete novice) On the submit button click event, I iterate through the controls in the page and build an array with information from the controls that have data in them, (filtering out the non-filled textboxes, and DDLs). All this works well, and I get an array called 'myInfo' with the columns with the control ID, and control values 'rvalue' (as string), with the number of rows equal to the filled textboxes and DDLs. I then step through the array and build a string with 'name=values' of all the rows in the myinfo array and email this as a message: ThisMessage = "" NoOfControls = myInfo.GetLength(0) For i = 0 To NoOfControls - 1 ThisMessage = ThisMessage & myInfo(i).ID.ToString & "=" & myInfo(i).rvalue.ToString & "; " Next SendMail(email address, ThisMessage) I also want to add this information to a database, appended by the IP address and datetime.now. Dim evdoDataSource As New SqlDataSource() evdoDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("SQLConnectionStringCK").ToString evdoDataSource.InsertCommandType = SqlDataSourceCommandType.Text Dim InsertMessage As String = """INSERT INTO evdoData (" NoOfControls = myInfo.GetLength(0) Dim k As Integer For k = 0 To NoOfControls - 1 InsertMessage = InsertMessage & myInfo(k).ID.ToString & ", " Next InsertMessage = InsertMessage & "IPNo, DateEntered) VALUES (" For k = 0 To NoOfControls - 1 InsertMessage = InsertMessage & "@" & myInfo(k).ID.ToString & ", " Next InsertMessage = InsertMessage & ", @IPNo, @DateEntered" & ")""" evdoDataSource.InsertCommand = InsertMessage I then similarly iterate through and do the insertparameters. Now here is the rub- (My all too often DUH moment!) When I look at the insertmessage in debug (and to be sure- I also show the insert string on a temporary debug label on the page), The insertmessage looks fine: "INSERT INTO EvdData (FirstName, Age, Email, Phone, Country, City, IPNo, DateEntered) VALUES (@FirstName, @Age, @Email, @Phone, @Country, @City, , @IPNo, @DateEntered)" However when the above code(evdoDataSource.InsertCommand = InsertMessage) is run, I get an error - the message with the error is: The identifier that starts with 'INSERT INTO ModelData (FirstName, Age, Email, Phone, Country, City, IPNo, DateEntered) VALUES (@FirsteName, @Age, @Email, @Phone,' is too long. Maximum length is 128 EH? When I actually copy the InsertMessage from the debug window and paste it manually after the command "evdoDataSource.InsertCommand = " It works, and I get the data inserted into the table.. -It would seem that I am probably missing something obvious in my complete "noviceness" . HELP! (oh and thanks a bunch in anticipation) _____________________________________________________________________________________________________________________ Its Easy --------------------------When you know How. Meanwhile Aaaaaaaaah .
Hello All, I want to insert a images into a database and these images save into a one perticular folder. and i want to use these Images into some Diffrent Diffrent area
Hello, I have a textbox on my formview which brings in a time from an sqldatasource. The time is displayed as 09:00:00 in the sql select statement i have a convert function - CONVERT (varchar, Time, 8) I am trying to alter the text e.g change to 09:30:00 and send it back to the database however i am having a lot of problems with that. Anyone know what i have to do to sort this. I think it might be something to do with the sql insert or the insert parameters as i dont know how to change the time String back to DateTime. Any help appreciated. Thanks in advance Mike.
This is a simple n00b question, but how can I insert the current date time into a datetime field in a database when submitting a form? I'm using the SQL DataSource control to do the inserting: <asp:SqlDataSource ID="SqlDataSourceMiguel" runat="server" ConnectionString="<%$ ConnectionStrings:SQLDataConnectionToInsertMiguelsTips %>"
I have a MS-SQL 2005 database that is in a one-to-many relationship that is like this: Table: Company CompanyID, company name, address, city, etc. Table Service States: CompanyID, StateID Table: States CompanyID, StateID, State The result is that you can have multiple states that are serviced assigned to any particular company. Then in my ASP, I have a form for adding new companies to the database. On this form I have text boxes for Company name, Address, etc. Then for adding the states that are serviced, since you can have multiple states that serviced I decided to put in a Grid. This works fine if I'm editing the Company since the CompanyID already exists, but when I'm adding a new company, I can't INSERT INTO the Table Service States, since I don't know what the CompanyID is yet. What would be the best way to handle this situation? I could probably put in a a ListBox with a Dropdown, then a little button with an add, add the items to the Listbox, then do an Insert on the Table Company, grab the companyID, then insert the items from the combobox. I'm wonder if anyone has any better suggestions or ideas to handle this. Thanks, marly