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.
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
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
I have a table changereport and network info.i insert a record with date of insertion plus chagereport id.then I have a xml file <ChangeReport> <Network-Info> <Version> 2.0</Version> <Highest-Ver> 2.0</Highest-Ver> <Description> WinSock 2.0</Description> <System-Status> Running</System-Status> <Max> 2.0</Max> <IP-address> 192.168.142.1</IP-address> <Domain-Name> samin</Domain-Name> <UDP-Max> 2.0</UDP-Max> <Computer-Name> SAMIN</Computer-Name> <User-Name> samin</User-Name> </Network-Info></ChangeReport> I want's to insert a record in network info table where field name are nodes name data should be the one against those nodes in xml file .How can I do it I am using sql server
What have I done wrong with this script?I'm getting an error The ConnectionString property has not been initialized.
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.InvalidOperationException: The ConnectionString property has not been initialized.
I'm trying to make a website that people can upload file to the server, then the webpage will automatically insert the username and the file name into the database. I have thought about this for couple days but still got nothing. can some one help me? can some one post a very simple aspx file that can insert a record to the sql database with C#? Not the code that generated by ASP.net 2.0! I want to see how to access the database manually. Thank you.
Hi, does anyone know what syntax I have to use if I want to use a trigger to insert into a different database. This is the code I have I'm just not sure how to get it to identify a different database.
CREATE TRIGGER History_replication ON [dbo].[History] FOR INSERT AS INSERT [dbo].[History] (this one shoul dbe on the History_copy db) (workdone,error) SELECT workdone,error FROM [dbo].[History]
SOS I am working with SQL 2000 located on a Networksolutions server and I have a Test record I inserted manually, but I am unable to insert a new record and get this error "can't insert new record to database". No doubt this is a no brainer, but I can't solve it. Many Thanks Who ever you are.
hi It seems that my code can insert data into memory, but not into the database. What I mean is that after "insert data", I can "read data", which I just insert. When I check the actual database table, it didn't get updated.
I am using VS 2005 and table designer. Regarding to this problem, is it related to any setting of setup of the database? I check the code, and I have no idea how it occurs.
Hi everyone !!! The past two days I am trying to make a survey to work ! Unfortunately I haven't accomplised yet :-(
So this is my problem... I am using ASP, MS-SQL for the survey. When I take the survey for the first time evetything is working and the fields are inserted correctly in the table ! If I take the survey for the second time... there is no insert in the table !!!
This is code...
dim Rs_Qu set Rs_Qu = myCon.Execute("Select * From QUESTION ") if Rs_Qu.Eof then myCon.Execute ("Insert into QUESTION (" & SqlStr_1 & ") values (" & SqlStr_2 & ")")
Also, I must tell you that when I use the SQL Pane and do ...
Insert into QUESTION (" & SqlStr_1 & ") values (" & SqlStr_2 & ") replacing of course " & SqlStr_1 & " and " & SqlStr_2 & " i can insert the entry !!!
hi. we have 1 production database and a 2nd backup database. one of our users accidentally deleted a case and we would like to get it back. our production database is updated nightly so none of the case's information would've changed.
how can i insert the data from the backup database to the production database? i need to copy one row. thanks for your help!
I need a little help. I want to load data to sdf database, with Visual Studio 2008. The database is on my PC. I want to copy to PPC, when it has the data. I thought it is easy... First I created a windows form application, and the database. I tried with TableAdapter.Insert(..), no exception, or error, but the database was still empty. DataSet.table.Rows.Add(newtableRow)+tableAdapter.Update works the same. My second attempt was to create a dataGridview. It can show data from the database, but can't insert. No error, but when I restart the application, the new row disappear. (Of course insert function is enabled.)
I was not able to realize the problem. The db is not read-only, and the conncection string works fine, and dataTableAdapter's insert method is also good.