Adding Data To A String
Sep 13, 2007
Hi,
I'm not a programmer by trade, so please be gentle with me! I am trying to add or insert data to the beginning of an existing string of data. The string is in one field in a table, with various options seperated by [ ].
An example of the current data is:
[Eye Color:TEST][Hair Color:TEST]
and I would like to add the data [# Persons:1] to the beginning of the string so it looks like this:
[# Persons:1][Eye Color:TEST][Hair Color:TEST]
Can anyone help me with the best way to do this?
View 6 Replies
ADVERTISEMENT
Mar 12, 2008
Hello, I am tring to add a string my database. Info is added, but it is the name of the string, not the data contained within. What am I doing wrong? The text "Company" and "currentUserID" is showing up in my database, but I need the info contained within the string. All help is appreciated!
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClientPartial Class _DefaultInherits System.Web.UI.Page
Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")
'First Command DataDim Company As String = ((CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Company"), TextBox)).Text)
Dim insertSQL1 As StringDim currentUserID As String = ((CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"), TextBox)).Text)
insertSQL1 = "INSERT INTO Company (CompanyName, UserID) VALUES ('Company', 'currentUserID')"Dim cmd1 As New SqlCommand(insertSQL1, con)
'2nd Command Data
Dim selectSQL As String
selectSQL = "SELECT companyKey FROM Company WHERE UserID = 'currentUserID'"Dim cmd2 As New SqlCommand(selectSQL, con)
Dim reader As SqlDataReader
'3rd Command Data
Dim insertSQL2 As String
insertSQL2 = "INSERT INTO Company_Membership (CompanyKey, UserID) VALUES ('CompanyKey', 'currentUserID')"Dim cmd3 As New SqlCommand(insertSQL2, con)
'First CommandDim added As Integer = 0
Try
con.Open()
added = cmd1.ExecuteNonQuery()
lblResults.Text = added.ToString() & " records inserted."Catch err As Exception
lblResults.Text = "Error inserting record."
lblResults.Text &= err.Message
Finally
con.Close()
End Try
'2nd Command
Try
con.Open()
reader = cmd2.ExecuteReader()Do While reader.Read()
Dim CompanyKey = reader("CompanyKey").ToString()
Loop
reader.Close()Catch err As Exception
lbl1Results.Text = "Error selecting record."
lbl1Results.Text &= err.Message
Finally
con.Close()
End Try
'3rd Command
Try
con.Open()
added = cmd3.ExecuteNonQuery()
lbl2Results.Text = added.ToString() & " records inserted."Catch err As Exception
lbl2Results.Text = "Error inserting record."
lbl2Results.Text &= err.Message
Finally
con.Close()End Try
End Sub
End Class
View 3 Replies
View Related
Mar 8, 2000
I would like to add an apostrophe in a string. eg. The boy's shoes.
Everytime I insert the record, the apostrophe gets drop. eg. The boys shoes.
Any suggestions??
Thanks, Vic
View 2 Replies
View Related
Aug 17, 2012
Basically I need to insert underscore in between a string when there is a space in the content of the string. For Example say we have string 'ABC XYZ', I've to convert it into something like this 'ABC_XYZ'. Some strings do not have space in between and I should not add underscore in such cases. I'm working with MSSQL Server 2008 version.
View 2 Replies
View Related
Jan 27, 2006
I'm looking for a string function (or any other quick way) for adding a leading zero to make a string two characters long. For example, if the input is '12' the result will be '12' but if the input is '1', the result will be '01'.
It's actually about making a month number two characters long but I've understood there is no way to make Datediff() to fix it for me.
I thought there might be a string function for this, like there is in many programming languages, but I can't find anything in BOL. I want to keep it simple, because it will be used in a Select and a Group By for aggregating data based on time intervals (year + month).
And, I assume I can't make Datepart() to return year + month directly, only one of the parts at a time.
View 14 Replies
View Related
Apr 23, 2007
Hello,
I would like to know if it is possible to add comments from different columns from table in sql into a single column. Please, see the attached table. I want all comments to be in one column. The outcome should be:
CONFIRMED NEED TO CONFIRM SIGNER AT <CR><LF> received e-mail:<CR><LF> Called Imran again today to see if .
Ideally, I would like to receive all comments in a single string of characters, perhaps separating the comments by <CR><LF>
Here is the table. Sorry my table doesnt look good, but it has the following fields: DATE, LEXNEX_DECISION, COMMENT
DATE LEXNEX_DECISIONCOMMENT
4/3/2007COMPLETECONFIRMED NEED TO CONFIRM SIGNER AT 4/3/2007COMPLETEreceived e-mail:
4/3/2007COMPLETECalled Imran again today to see if .
Help!
View 1 Replies
View Related
Oct 19, 2007
for example : " server={0};database={1};trusted_connection=true;application name={3}"
The article SqlConnection.ConnectionString Property refer this term,but doesn't specify use.
I want to know whether it will affect sql server and how to find its effect
thanks
View 3 Replies
View Related
Sep 3, 2014
add a number to the end of an ID to create a series.For example, I have an EventID that may have many sub events. If the EventID is 31206, and I want to have subEvents, I would like have the following sequence. In this case, lets say I have 4 sub Events so I want to check the EventID and then produce:
312061
312062
312063
312064
How can I check what the EventID is, then concatenate a sequence number by the EventID?
View 9 Replies
View Related
Nov 2, 2006
I am trying to insert a row into a table of Microsoft SQL Server 2000.
There are various columns.
[SNO] [numeric](3, 0) NOT NULL ,
[DATT] [char] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
,
[DATTA] [char] (3000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
,
[CODECS] [char] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
,
The [DATTA] column is causing a problem. Even if I am trying to put only 1700 character string into [DATTA], the java code throws the following exception:-
StaleConnecti A CONM7007I: Mapping the following
SQLException, with ErrorCode 0 and SQLState 08S01, to a
StaleConnectionException: java.sql.SQLException: [Microsoft][SQLServer 2000
Driver for JDBC]Connection reset
at
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
Why is it throwing an exception even though the sum-total of this row doesn't exceed 8000 characters?
Can anyone please tell me what's wrong?
View 6 Replies
View Related
Apr 3, 2014
I need to see inside a SSIS 2012 project a new SSIS installed component, but in the SSDT 2010 I cannot see the SSIS Data Flow Items tab for adding data source/data destination respect to the choose toolbox items pane.
View 4 Replies
View Related
Jan 5, 2006
I need to know what a table's max row Identity is part way thru a data flow. I can't get it at the beginning of the data flow. I need to either (1) add it to the data buffer part way thru or (2) set it into a package variable and then reference the var in a script component.
I've not found a way to add a database column to the data buffer without doing a lookup for each row (too slow and not appropriate here) or some goofy oledb source and then merge join into the data buffer on a contrived join.
I've read questions about referencing package vars in scripts but I can't get that to work. DTS.Variables("varname").Value isn't recognised when I code it up.
Anyone have an idea or solution for either one of these? If you're gonna explain the script code, please include the entire snipet including the INCLUDEs, etc.
View 8 Replies
View Related
Sep 17, 2004
I have some website work lined up and it involves some simple modifications to a MS SQL 2000 server. What I'll need to do is add some new data fields and insert some data.
I have some experience with databases - MS Access and MySQL, but I have never used or seen MS SQL 2000. My question is, is this a relatively simple thing to do for someone who hasn't used it before? I can do these things quite simply in Access or MySQL, so is MS SQL 2000 going to be any different?
Also, does anyone know of any free tutorials online that would help me out?
Thanks
View 1 Replies
View Related
May 30, 2006
Hi guys,
this is going to sound like a ridiculous question, but when you are first adding all your records, do you need to add all the foreign key data yourself so that it ties together?
eg. If studentid =1 in first table, then you need to add record for student id in bridging table so that studentid= 1:teacherid=1 and add teacher id=1 if it is not autoincrementing????
Thanks
Cm
View 5 Replies
View Related
Jul 10, 2006
Hi there,I am currently setting up a registration system where customers can registers their details and the details of the product, using ASP.net and MS SQL.There is a column called customerID in the Custoemrs table, and a column of the same name in the Products table, so that I can have relationships between the tables.For obvious reasons (ie. people that quit half-way through), I want to hold all the information until the end. The ID in the Customer table is unique, and auto-increasing, and therefore not assigned until the data enters the database.However, I wish to submit information to the Products table at the same time, but what shall I put in for the custoemrID (which hasn't yet been assigned)Thank you in advance for your help,Nathair
View 2 Replies
View Related
Jan 15, 2006
I'm new at this and wondering if someone would have the heart to help.I want to know how to add data into a database. Here's the details:I have a sqldatasource( sqldatasource1) attached to a database with a table named customers.The table(customers) has one field named 'Name' with datatype varchar(50)I have a textbox (textbox1) and a button (button1)I want to insert the text into textbox1 into my database. how can i do that?
View 3 Replies
View Related
Dec 8, 2004
Hi!
Is it possible to add/delete/modidy data through views?
What is the major difference between SQL Stored procedure & SQL function?One diff i know is using SP we can execute transact-sql statements.Is there any other difference?
Thanks in advance
View 1 Replies
View Related
Mar 6, 2014
I'm currently in an SQL internship, and am running into an issue with a project they've given me. Primarily, he's asking me to try to get a table containing student entry testing information to update with a new column that's supposed to contain the testing dates. This in mind, there is another table that contains testing data, and who's students are grouped by date, the data in each group all coming from the students table. Issue is, I don't know how to get the testing dates from the TestData table into the Students table. There's already a relationship set up between the TestID fields on the TestData table (PK) and the Students table (FK), so I don't think I can set up a new relationship to get it working.
View 1 Replies
View Related
May 11, 2006
Hi
I'm am using SQL Server 2005 Express on my home PC.
To practice some of the SQL skills I learned on a course I was recently on, I am trying to build a mini database which I can run some queries from.
I have created some tables and added columns to these tables. However, I cannot find how to add data to these columns.
I'm sure it's pretty simple but I just can't find it! Can anyone help??
Cheers!
View 4 Replies
View Related
Apr 15, 2006
Hello everyone, I finally got the SDF file on my pocket pc, and now am having trouble loading the data into the listview. I am not sure where I am going wrong, but the code is listed below. Any ideas? Thanks so much, everyone.
private void LoadList(string szSQL)
{
// Clear out anything that might already be in the list
CollectionList.Items.Clear();
// save off the SQL Statement
m_szCurrFilter = szSQL;
// Throw Data into the list
SqlCeCommand sqlLoadEvents = m_cConn.CreateCommand();
sqlLoadEvents.CommandText = szSQL;
SqlCeDataReader rReader = sqlLoadEvents.ExecuteReader();
// roll through the reader and put items into the list
while ( rReader.Read() )
{
ListViewItem lvItem = new ListViewItem(rReader.GetValue(rReader.GetOrdinal("ca_id")).ToString()); //Nmbr
// Note: Since a "tag" is not supported by the compact framework, we'll use the "ImageIndex"
// property to hold the movie ID, this way we can find it later when the user clicks
// on an item
lvItem.ImageIndex = (int)rReader.GetValue(rReader.GetOrdinal("ca_id"));
lvItem.SubItems.Add(rReader.IsDBNull(rReader.GetOrdinal("ca_titel")) ? "" : rReader.GetValue(rReader.GetOrdinal("ca_titel")).ToString()); // Title
lvItem.SubItems.Add(rReader.IsDBNull(rReader.GetOrdinal("ca_alter")) ? "" : rReader.GetValue(rReader.GetOrdinal("ca_alter")).ToString()); // Rating
lvItem.SubItems.Add(rReader.IsDBNull(rReader.GetOrdinal("ca_sex")) ? "" : rReader.GetValue(rReader.GetOrdinal("ca_sex")).ToString());// Gender
CollectionList.Items.Add( lvItem );
}
}
View 14 Replies
View Related
Nov 15, 2007
Very basic question here but I need to add a form to a page so it adds content, its as simple as that. I've done this kind of using a <asp.Formview> tag and it works, but becuase I think I've used a form view I have to click add to insert data first. Should I be using the <asp:formview> tag or is it a problem with the templates?
<asp:FormView ID="FormView1" runat="server" DataKeyNames="ContentID" DataSourceID="ObjectDataSource1"> <InsertItemTemplate> Resource :<asp:DropDownList ID="ResourceIDTextBox" runat="server" Text='<%# Bind("ResourceID") %>' DataSourceID="ObjectDataSource2" DataTextField="Resource" DataValueField="ResourceID"> </asp:DropDownList><br /> Headline: <asp:TextBox ID="HeadlineTextBox" runat="server" Text='<%# Bind("Headline") %>' Width="451px"></asp:TextBox><br /> Date: <asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>'> </asp:TextBox><br /> Body: <FTB:FreeTextBox id="FreeTextBox1" runat="Server" Text='<%# Bind("Body") %>' Width="542px" /> <br /> ImageURL: <asp:TextBox ID="ImageURLTextBox" runat="server" Text='<%# Bind("ImageURL") %>'> </asp:TextBox><br /> OpeningPara: <asp:TextBox ID="OpeningParaTextBox" runat="server" Text='<%# Bind("OpeningPara") %>'> </asp:TextBox><br /> Ret: <asp:TextBox ID="RetTextBox" runat="server" Text='<%# Bind("Ret") %>'> </asp:TextBox><br /> Man: <asp:TextBox ID="ManTextBox" runat="server" Text='<%# Bind("Man") %>'> </asp:TextBox><br /> Pro: <asp:TextBox ID="ProTextBox" runat="server" Text='<%# Bind("Pro") %>'> </asp:TextBox><br /> Com: <asp:TextBox ID="ComTextBox" runat="server" Text='<%# Bind("Com") %>'> </asp:TextBox><br /> IndustryID: <asp:TextBox ID="IndustryIDTextBox" runat="server" Text='<%# Bind("IndustryID") %>'> </asp:TextBox><br /> ContentTitle: <asp:TextBox ID="ContentTitleTextBox" runat="server" Text='<%# Bind("ContentTitle") %>'> </asp:TextBox><br /> Status: <asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>'> </asp:TextBox><br /> Pub: <asp:TextBox ID="PubTextBox" runat="server" Text='<%# Bind("Pub") %>'> </asp:TextBox><br /> Fin: <asp:TextBox ID="FinTextBox" runat="server" Text='<%# Bind("Fin") %>'> </asp:TextBox><br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert"> </asp:LinkButton> <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"> </asp:LinkButton> </InsertItemTemplate> <ItemTemplate> <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="Click here to Add New Content"> </asp:LinkButton> </ItemTemplate> </asp:FormView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="ContentADDMethod" TypeName="DataSet2TableAdapters.ContentADDAdapter" UpdateMethod="Update"> <DeleteParameters> <asp:Parameter Name="Original_ContentID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="ResourceID" Type="Int32" /> <asp:Parameter Name="Headline" Type="String" /> <asp:Parameter Name="Date" Type="String" /> <asp:Parameter Name="Body" Type="String" /> <asp:Parameter Name="ImageURL" Type="String" /> <asp:Parameter Name="OpeningPara" Type="String" /> <asp:Parameter Name="Ret" Type="String" /> <asp:Parameter Name="Man" Type="String" /> <asp:Parameter Name="Pro" Type="String" /> <asp:Parameter Name="Com" Type="String" /> <asp:Parameter Name="IndustryID" Type="Int32" /> <asp:Parameter Name="ContentTitle" Type="String" /> <asp:Parameter Name="Status" Type="String" /> <asp:Parameter Name="Pub" Type="String" /> <asp:Parameter Name="Fin" Type="String" /> <asp:Parameter Name="Original_ContentID" Type="Int32" /> <asp:Parameter Name="ContentID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="ResourceID" Type="Int32" /> <asp:Parameter Name="Headline" Type="String" /> <asp:Parameter Name="Date" Type="String" /> <asp:Parameter Name="Body" Type="String" /> <asp:Parameter Name="ImageURL" Type="String" /> <asp:Parameter Name="OpeningPara" Type="String" /> <asp:Parameter Name="Ret" Type="String" /> <asp:Parameter Name="Man" Type="String" /> <asp:Parameter Name="Pro" Type="String" /> <asp:Parameter Name="Com" Type="String" /> <asp:Parameter Name="IndustryID" Type="Int32" /> <asp:Parameter Name="ContentTitle" Type="String" /> <asp:Parameter Name="Status" Type="String" /> <asp:Parameter Name="Pub" Type="String" /> <asp:Parameter Name="Fin" Type="String" /> </InsertParameters> </asp:ObjectDataSource> <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="DataSet2TableAdapters.ResourcesTableAdapter"> <InsertParameters> <asp:Parameter Name="Resource" Type="String" /> </InsertParameters> </asp:ObjectDataSource>
View 1 Replies
View Related
Dec 31, 2007
Hi..
When I try to add new item "SQL Data Base" the following error generate:
Failed to generate a user instance of SQL server due to a failure in starting the process for the user instance. The connection will be closed.
what is mean? what is its reason? how I can solved?
Please help me as soon as possible..
Thanks..
View 2 Replies
View Related
Apr 11, 2006
EX: I have a table for products, and each product has a quantity. How can I add up the QTY field in all the rows to find out the total QTY of all the products.Any help would be greatly appreciated.gkc
View 4 Replies
View Related
Feb 11, 2002
We are using SQL server 7.0 as RDBMS for BaaN ERP. We have
created the database file in E: drive. Now E: drive is going to be
exhausted, We are trying to add a new file at different location. When
we add the file into database it creates a file with default extension .ndf
but previous file has the extension .mdf. should we change the extension
of new file to .mdf or we should continue with default extension .ndf.
is it necessary to add a secondary file group or we add a file to the
existing primary group.
thanx in advance
madhu p menon
View 1 Replies
View Related
Jun 11, 2008
I created a database using SSMS, now I want to add sample data.
What are the methods of adding sample data from the server?
Do I need to use the SQL Server client or can I use the SQL command line or query window?
Thank you,
Goldmember
View 1 Replies
View Related
Jan 24, 2008
We have 1 TB database and we recently got space so
1) can i add data files and put in different disk in production hours
2) what are the effects of doing this.
JUst want to get expert advise
View 1 Replies
View Related
Nov 14, 2007
I try to add data to SQL via Access Forms. When I add a data and open tables in Access which are connected to SQL, I can see my new datas. But if I open tables in SQL Server Management Studio I can not see any of those new datas. What should I do to solve this problem. I will be very happy if you can help me about this matter.
Thanks in advance...
Berk
View 3 Replies
View Related
Aug 22, 2006
I'm attempting to create a new GUI for an existing MySQL database I have. I would like to program this application using Visual Studio 2005 using the Visual C++ or C# language.
I'm having trouble connecting to the database though. When I attempt to add it as a data source I get the following error: "Could not retrieve schema information for table or view"
I'm using the MySQL ODBC driver version 3.51 and MySQL versoin 5.0. Visual Studio 2005 Professional Edition.
Can someone help me get this project started? How do I connect to my database?
Thanks!
View 4 Replies
View Related
Jan 22, 2008
HI all.
I am new to ADO.NET and have a emergency problem to slove.
I am using VS 2005 to open a solution that created by previous VS. After the solution is upgraded by VS, I was gonna add a data souce to the form. The destinated database is a sample called Northwind. But right after I want to add a table called "employee" as the object database in dataset, I got an error "error using the dropdown: Could not get type information for 'Getting_Started.NorthwindDataSet'"
I created a test form and did the same procedure but got no error at all. So I guess there must be something wrong with using VS 2005 to open solution created by previous VS.
Can anyone help me solving this problem? Thanks.
View 4 Replies
View Related
Feb 6, 2006
This may sound a bit weird...but here it goes. I have in my SSRS 2005 report one table. In that table I have:
Header1
Groupp1
Footer1
Some of the fields in the Group look like this:
Company Number Branch FeeGoal
The problem I have is FeeGoal. It comes from a table that is simply joined to my main dataset (via the dataset's stored proc) on company number. So I do not want this one summed. I want it to be the value the user entered for that company only, not summed. I have an ASP.NET input form where each of the companies has one FeeGoal input field. I then update all company records in a temp table where they have a FeeGoal field....and update each FeeGoal Field for that company with the FeeGoal the user entered into my form.
IN the report group, I do not put sum for this field, I just put
=Fields!FeeGoal.Value
So that I end up with basically Top 1 of FeeGoal for the particular company in the group. The problem I have now is how to sum up all FeeGoals without summing up of the same FeeGoal values for each company. Remember, I just want to sum up all Top 1 values for FeeGoal in the Group.
How do I do this?
Sample Data
CompanyName Field1 Field2 FeeGoal
ABC 100 2000 200000
ABC 100 232 200000
ABC 112 2 200000
DCE 23 223 300000
DCE 203 200 300000
DCE 24 229 300000
EER 22 344 400000
EER 220 111 400000
Picture that as my Dataset
Now in my Report, I have the followingfields in my Group, grouped by CustomerNumber(not shown)
Group1
CustomerName Field1 Field2 FeeGoal
In my FeeGoal, I simply put =Fields!FeeGoal.Value, not =SUM(Fields!FeeGoal.Value) because I want to only sum Distinct, not 30000 + 30000 + 30000 for example..I only want to show 300000 for Company DCE
But in the Footer, I put the same Fields!FeeGoal.Value. Of course that only returns the top result which is 20000 for company ABC.
If I then try =SUM(Fields!FeeGoal.Value), it's way over inflated because it's counting the FeeGoal multiple times per customer, I only want to sum up each common instance.
FeeGoal is a unique case, usually you let the grouping do it's work but I don't want to overinflate my total for FeeGoal in my Footer.
If there is some way to do =SUM(Top 1 FeeGoal) or SUM(Distinct FeeGoal) in SSRS 2005 VB syntax somehow in the expression builder, this is the only way to get this to be accurate unless someone else knows...
Here's a couple of screen shots. You'll see the overinflated FeeGoal sum:
http://www.photopizzaz.biz/feegoal1.jpg
http://www.photopizzaz.biz/feegoal12.jpg
View 1 Replies
View Related
Oct 18, 2006
When I enter over 4000 chars in any ntext field in my SQL Server 2005 database (directly in the database and through the application) I get an error saying that the data could not be updated because string or binary data would be truncated.Has anyone ever seen this? I cannot figure out what is causing it, ntext should be able to hold a lot more data that this...
View 7 Replies
View Related
Feb 12, 2008
Hello,
I am wondering what conversion rules apply, when a string, which contains a number, is saved to a SQL Server 2005 into a column of type decimal.
This is the code I€™m using (C++):
CString cValue = "0.75"
_variant_t vtFieldValue;
vtFieldValue = _variant_t(cValue)
pRecordSet->Fields->Item["MyColumn"]->Value = vtFieldValue;
"pRecordSet" is an ADO recordset. The database column "MyColumn" is of type "decimal(19,10)".
The most important question for me is, if the regional settings of the database server or the regional settings of the client PC are considered during the conversion from the string to the decimal value. For example in standard French regional settings the "." would not be recognized as decimal separator.
I am also wondering if the language of the database instance, in which this data is saved, is considered during this conversion or any other settings of this database instance.
So my general question is: Does anybody know exactly what rules apply during the above mentioned conversion?
Thank you for your help.
Regards,
Volker
View 2 Replies
View Related
Nov 7, 2007
I want to insert a record with fields let say"ProductCode, Name" to a table with records like "ProductCode, Name, NumberofItems". I get mismatching errors "Conversion from string "INSERT INTO dbo.t_Shopping(Productcod" to type 'Double' is not valid.". Note the missing last letter. ProductCode and Name are both varChars, NumberofItems is int in table and double in my code. This is my insertion script ".CommandType = CommandType.Text = "INSERT INTO dbo.t_Shopping(ProductCode, Name, NumberofItems)SELECT ProductCode, Name, @NumberofItems FROM dbo.t_Product WHERE ProductCode=@ProductCode"I have asked this question previously in an other mail, but probably because that thread was marked solved, no one answered.The whole code is like this: I translated some names. I hope its still valid. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim NumberofItems As Double = 1 Dim conn As New SqlConnection("Data Source=DV2SQLEXPRESS;Initial Catalog=testaus;Integrated Security=True") Dim row As DetailsViewRow = DetailsView1.Rows(0) Dim ProductCode As String = row.Cells(1).Text Dim cmd As New Data.SqlClient.SqlCommand Dim param As New SqlParameter() TextBox1.Text = ProductCode With cmd .Connection = conn .CommandType = CommandType.Text = "INSERT INTO dbo.t_Shopping(ProductCode, Name, NumberofItems)SELECT ProductCode, Name, @NumberofItems_ FROM dbo.t_Product WHERE ProductCode=@ProductCode" .Parameters.AddWithValue("@ProductCode", ProductCode) .Parameters.AddWithValue("@NumberofItems", NumberofItems) ' End With Try conn.Open() cmd.ExecuteNonQuery() Catch ex As Data.SqlClient.SqlException Throw New ApplicationException("An error occurred while trying to insert the record") Finally conn.Dispose() End Try RegardsLeif
View 7 Replies
View Related
May 21, 2008
I have 3x6 textbox lay out, QTY, Descp, Cost, with submit button with followin code...., insert function has too many function, anyone know how to work thiis type of data entery?? Thanks in advanc.Dim Quntityx() As Integer = {txtQ1.Text, txtQ2.Text, txtQ3.Text, txtQ4.Text, txtQ5.Text, txtQ6.Text}
Dim xDex() As String = {txtD1.Text, txtD2.Text, txtD3.Text, txtD4.Text, txtD5.Text, txtD6.Text}Dim xcost() As Decimal = {txtC1.Text, txtC2.Text, txtC3.Text, txtC4.Text, txtC5.Text, txtC6.Text}
Dim i As IntegerFor i = 0 To 5
itemInput.InsertParameters.Add("RequestN", RequestN)itemInput.InsertParameters.Add("Description", xDex(i))
itemInput.InsertParameters.Add("Cost", xcost(i))itemInput.InsertParameters.Add("Quantity", Quntityx(i))
itemInput.Insert(i)
Next i
View 5 Replies
View Related