Inserting Problem With Sqlserver And Vb.net

Jun 20, 2006

hi there i ve got a quick question regarding table and adding primary key and values
Basically i have a empty table called ReligionType and have two fields ReligionID and ReligionName. I would like to add a new data into this table (i set the indentity and identity seed in sql server but when i execute the value in sqladapter it give me error on

"An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll"

This is the code that i wrote in vb.net


con2.Open() //sql connection

Me.SqlDataAdapter2.Fill(DataSet1)

Me.SqlInsertCommand2.CommandText() = "Insert into ReligionType(ReligionName) Values (@ReligionName) SELECT @@identity As 'ReligionID' GO"

Me.SqlInsertCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))

Me.SqlInsertCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ReligionName", System.Data.SqlDbType.NVarChar, 20)).Value = inputdata.Text

Me.SqlInsertCommand2.ExecuteNonQuery()

'Me.SqlDataAdapter2.Fill(DataSet1)
con2.Close()

so where did i go wrong ?
please help

View 4 Replies


ADVERTISEMENT

Inserting Images In Sqlserver

Mar 12, 2007

lakshmi writes "I tried to insert in sqlserver using textcopy.exe. But it is not inserting.
how to insert images in sqlserver? Pls reply it is most urgent for me."

View 1 Replies View Related

Inserting Data Into SQLServer Made Easy...(Hopefully)

Jun 7, 2007

First, thank you all for the help so far.My new, broader Question is this: What is the most efficient (read easiest) way to code in an inset statement into a remoste SQL 2003 database from IIS 6 running asp.net 2.0?Here is the situation: I have a form that requires the user to be signed in. I then want to get the value of a text box TBOne(String), a dropdownlist DDOne(Text),  another Textbox TBTwo (int) and insert these values in to a NEW row of a database (DBTest) into table TTest, with the UserName (String), and todaysdate (SmallDateTime).I am a JSP programmer, and it's fairly easy to do in JSP, but I am trying to leverage the SQL Datasource, to make my life easier.Is there a simple way to do this? Something like:String username=page.someintg.User.name;String TBOne=TBOne.text;...Insert into DBTest.TTest Values(username, TBOne, ...)  ? TIA Dan 

View 5 Replies View Related

Problem In Displaying Or Inserting Data Into Sqlserver Tables Using Utf

Apr 18, 2004

i have such a error in my sql server db
i examined arabic_ci_as and SQL_Latin1_General_CP1256_CI_AS
but in my web pages that uses utf-8 codepage that retrieves data using ado and asp scripting the ouput or inserted that dispalyed in both of query analyzer and Enterprise manager replaces or display '?????' for characters .
i am using nchar and nvarchar and ntext

View 5 Replies View Related

Class Method Is Smoking Fast When Executed Outside Of SQLServer, Dog Slow As A CLR Function Is SQLServer - Anyone?

May 10, 2007

We have a static class that makes an HTTPWebRequest to get XML data from one of our vendors. We use this as input to a stored proc in SQLServer2005. When I compile this class and call it from a console application in visual studio it executes in milliseconds, everytime. When I compile it, create the assembly and clr function and execute it in SQLServer, it takes around 14 seconds to execute the first time, then on subsequent requests it is again really fast, until I wait for 10 seconds and re-execute, once again it is slow the first time and then fast on subsequent requests. We do not see this behavior when executing outside SQLServer. Makes me think that some sort of authentication is perhaps taking place the first time the function is run in SQLServer? I have no idea how to debug this further. Anyone seen this before or have any ideas?



Here is the class:






Code Snippet

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace Predict.Services
{
public static class Foo
{
public static string GetIntradayQuote(string symbol)
{
string returnQuote = "";

HttpWebRequest request = (HttpWebRequest)(WebRequest.Create("http://data.predict.com/predictws/detailed_quote.html?syms=" + symbol + "&fields=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,28,30"));

request.Timeout = 1000;

HttpWebResponse response = (HttpWebResponse)(request.GetResponse());

StreamReader streamReader = new StreamReader(response.GetResponseStream());

returnQuote = streamReader.ReadToEnd();

streamReader.Close();
response.Close();

return returnQuote;
}
}
}



When I run call it from a console app it is fine.



I compile it into a dll and then create the assembly and function as follows:






Code Snippet

drop function fnTestGetIntradayQuoteXML_SJS

go

drop assembly TestGetIntradayQuoteXML_SJS

go

create ASSEMBLY TestGetIntradayQuoteXML_SJS from 'c:DataBackupsCLRLibrariesTestGetIntradayQuote_SJS.dll' WITH PERMISSION_SET = EXTERNAL_ACCESS

go

CREATE FUNCTION fnTestGetIntradayQuoteXML_SJS(@SymbolList nvarchar(max)) RETURNS nvarchar(max) AS EXTERNAL NAME TestGetIntradayQuoteXML_SJS.[Predict.Services.Foo].GetIntraDayQuote

go



declare @testing nvarchar(max)

set @testing = dbo.fnTestGetIntradayQuoteXML_SJS('goog')

print @testing





When I execute the function as above, again, really slow the first time, then fast on subsequent calls. Could there be something wrong with the code, or some headers that need to be set differently to operate from the CLR in SQLServer?



Regards,



Skipper.

View 1 Replies View Related

Problem Unicode Data 0x2300 In SQLServer 2000 SQLServer 2005 Express

Sep 20, 2006

Hi experts;
I have a problem with unicode character 0x2300
I created this table
create table testunicode (Bez nchar(128))

Insert Data
insert into testunicode (Bez)values('Œ€„¢')
with 2 Unicode characters
Œ€ = 0x2300
„¢ = 0x2122

Selecting the data
select Bez from testunicode
I see
"?„¢"

„¢ = 0x2122 is ok but instead of 0x2300 there is 0x3f

When I modify the insert statement like that ( 8960 = 0x2300 )
insert into testunicode (Bez)values(NCHAR(8960)+'„¢')

and select again voila i see
"Œ€„¢"
Does anyone have an idea?

Thanks

View 1 Replies View Related

Trying To 'load' A Copy Of A SQLServer 2000 Database To SQLServer 2005 Express

Apr 18, 2008



I am trying to 'load' a copy of a SQLServer 2000 database to SQLServer 2005 Express (on another host). The copy was provided by someone else - it came to me as a MDF file only, no LDF file.

I have tried to Attach the database and it fails with a failure to load the LDF. Is there any way to bypass this issue without the LDF or do I have to have that?

The provider of the database says I can create a new database and just point to the MDF as the data source but I can't seem to find a way to do that? I am using SQL Server Management Studio Express.

Thanks!!

View 1 Replies View Related

MIcrosft SQLServer Best Practices Document On Securing SQLServer

Jul 29, 2005

I'm chasing after a documetn that was available on one of the Microsoftwebsites that was titled somethign like "MS SQL Server Best Practices"and detailed a nyumber of best practices about securing the server.Included in this was revoking public access to the system tableobjects.Can someone post the URL where I can pick this up, or drop me a note oncontacting them for a copy of the document?

View 2 Replies View Related

Replacing Sqlserver 2000 With Sqlserver 2005 Express

Jun 14, 2006

I have an app that uses a sqlserver 2000 jdbc driver to connect to a sqlserver 2000.

Is it possible to do a direct replacement of sqlserver 2000 with sqlserver 2005 express just by reconfiguring the app to point to the express? The app would still be using the sqlserver 2000 jdbc driver to try and make the connection.

If that is a possibility, what can be some differences in the configuration? Previously with 2000 the config information I entered is:

server name: "machinename"( or ip). I've also tried "machiname/SQLEXPRESS"

DB name: name of db instance

port: 1433(default)

user and pass.

My attempts so far results in

"java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket."

and

"java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL."

View 1 Replies View Related

Upgrade SQLServer Mobile (.sdf) Database To SQLServer 2005

Feb 9, 2006

Hello,

I have an SQLServer Mobile database, and I would like to know if there is a way to upgrade it to SQLServer 2005 (.mdf) database. My database has no records in it, just the structure (tables etc). What I am actually asking is if I can create automatically a new SQLServer 2005 Database with the same structure as my existin SQLSErver Mobile database

Thanks in advance,

TassosTS

View 1 Replies View Related

SQLSERVER 2005 X64 Linked Server To SQLSERVER 7.0

Jun 20, 2007

Hello people.

I am in the process of planning a server upgrade to sql2005 x64.

I created 2 linked servers: one to a SQL2000 sp4 server and one to a SQL7.0 SP3.

I have the following error when I query the linked servers.
OLE DB provider "SQLNCLI" for linked server "IVDM2K" returned message "Unspecified error".
OLE DB provider "SQLNCLI" for linked server "IVDM2K" returned message "The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator.".
Msg 7311, Level 16, State 2, Line 1
Cannot obtain the schema rowset "DBSCHEMA_TABLES_INFO" for OLE DB provider "SQLNCLI" for linked server "IVDM2K". The provider supports the interface, but returns a failure code when it is used.

I am aware of KB 906954.
http://support.microsoft.com/default.aspx?scid=kb;en-us;906954

I applied the instcat.sql on the SQL2000SP4 server and my linked server issues for that one are gone.

However, I ran the instcat.sql script on the SQL7.0 sp3 server and the linked server is still giving me an issue.

Can someone help me find a solution to this?

View 1 Replies View Related

Post Update For SQLServer SP2--is There One For SQLServer Express?

Apr 18, 2007

Regarding KB935356, is there a "post" service pack 2 update for SQLServer Express?



Thanks.

View 7 Replies View Related

How To Import Access To SQLServer With Parameter From SQLServer, Help Pls!

Jul 8, 2006

Hello Expert!

I have 2 Database €“ Access & SQLServer(ver 7)

I need to Import Data TblShift from Access to SQLServer €“ using DTS I€™ve done this successfully!

Now I want to use parameter so I only importing record within range (e.g. ShiftDate BETWEEN 05-24-2006 AND 06-23-2006)

In SQLServer, I have created table to store the date range as following:

TblParameter
DateFrom: 04/24/2006
DateTo: 05/23/2006

How do I use the date range from TblParameter(SQLServer) to import record from TblShift(Access) using DTS?

Is this possible or any better solution for this?

TIA

Regards,

View 4 Replies View Related

Differences Between Sqlserver 2000 And Sqlserver 7.0

Dec 29, 2005

Hi Friends,
 
Can some please let me know the differences between sqlserver 2000 and sqlserver 7.0

View 1 Replies View Related

Difference In SQLSERVER/sqlExpress And SQLSERVER

Jun 6, 2007

Hi,
I am new to SQL Server 2005. I tried connecting to my local machine by using my machine name as Server name and then tried running the following query:
SELECT * FROM SYS.Objects. It gives me following error:
Invalid object name 'sys.objects'.

Whereas, if I connect to my local machine using mahcinenameSQLEXPRESS, then the above mentioned query runs fine.

Why is this difference? What is the difference when I login in these 2 different ways.
Any help would be appreciated.

Thanks in advance.

Any help

View 1 Replies View Related

How To Transfer Data From A SqlServer Database To A SqlServer Express Database

Mar 29, 2006

Is there a way to transfer data from a SqlServer db to a SqlServer Express db. I tried to use the backup file of SqlServer, but this file is not valid for SqlServer Express. Or there any alternatives?

thanks,

Henk

View 7 Replies View Related

Inserting Data Into Two Tables (Getting ID From Table 1 And Inserting Into Table 2)

Oct 10, 2007

I am trying to insert data into two different tables. I will insert into Table 2 based on an id I get from the Select Statement from Table1.
 Insert Table1(Title,Description,Link,Whatever)Values(@title,@description,@link,@Whatever)Select WhateverID from Table1 Where Description = @DescriptionInsert into Table2(CategoryID,WhateverID)Values(@CategoryID,@WhateverID)
 This statement is not working. What should I do? Should I use a stored procedure?? I am writing in C#. Can someone please help!!

View 3 Replies View Related

Not Be Able To Reinstall SQLServer 2005 After SQLServer 2005 SP I

May 9, 2006

Hi every body,

I have SQLServer 2005 runs well for months and stop working after install SqlServer2005 SP1. I try to reinstall the SQLServer 2005 but I have problem when install work station component on my and the error is "There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor". Please help me to fix this bug. I do not want to reformat my machine.

John Dang



View 1 Replies View Related

Inserting Data To Text File From Database And Inserting Data Back To Database From Text File

Aug 7, 2007

Hello friends....
I am looking for 2 things(using c#.net or vb.net and sql svr 2000)
1.convert data from sql server 2000 database (say customers table from northwinds database) to a text file(separated by commas or just plain space)
2.Insert the data from text file back to database.
Can someone pls give me the detailed code to achieve this....really need this on urgent basis.......Thank You.

View 10 Replies View Related

Inserting '

Jan 16, 2008

How can I insert a value that includes '  ?
My insert string looks like this: "INSERT INTO table(field1) VALUES ( ' " + value1 + " ' )"
When value1 has ' in it, I get an error.

View 5 Replies View Related

Inserting More Than 1 Value

Sep 30, 2005

I have the following code for SQL2000:
It only works if the sub-query returns only 1 values.... anyone knows how I can solve this?
thx a lot!!!

INSERT INTO Table1(SourceName, CreatedBy, CreateDate, IsSuccess, datadate)
SELECT 'Data_01', user, GetDate(), 1,
(
SELECT DISTINCT T1_Dummy.[TRANSACTION DATE]
FROM T1
WHERE T1.[TRANSACTION ID] NOT IN
(
SELECT T.TRANSACTION_ID
FROM T
)
)
FROM T1
GROUP BY [Transaction Date]

View 3 Replies View Related

Inserting And Then Getting The Key

Apr 4, 2007

Hi,

I am moving one database to another (different scemas) using SSIS. The destination database uses autogenerated keys. In order to preserve referential integrity I have to keep track of the keys generated when doing inserts in various tables. I use a staging table to save the keys generated by the insert command. I use this as a lookup table later on to find the foreign keys in order to link newly inserted records. The only way that I could find to get the key back after an insert was to create a Script component that does the insert and then executes "SELECT @@IDENTITY". After that I use an OLE DB Command to update the record in the staging database. Is there a better way of doing this? It seems to me that this is not a proper use of the Script component, but if I want to use OLE DB destination or OLE DB Command I cannot get the key back. Also, I am not allowed to use any stored procedures or change the destination database in any way.

View 4 Replies View Related

LOCK DB WHEN INSERTING

Jul 19, 2006

Hello.
I need to insert some records to an accounting table and calculate the balance after that. Thus, other users can be trying to do the same. How to lock the db and make the other users wait until the right moment? I'm using SqlDataSource to do that.
Thanks.

View 7 Replies View Related

Inserting A Default Value

Sep 3, 2006

I have populated an SQLdata table from an XML datasource usinmg the bulk command. In my SQL table is a new column that is not in the XML table which I would like to set to a default value. Would anyone know the best way to do this. So far I can's see how to add this value in the Bulk command. I am happy to create a new command that updates all the null values of this field to a default value but can't seem to do this either as a SQLdatasource or a APP Code/ Dataset. Any suggestions or examples where I can do this.Many thanks in advance

View 1 Replies View Related

Help On Inserting Data To DB

Sep 11, 2006

Hi,I m using Microsoft Visual Studio 2005 and SQL server 2000. I have 2 textboxes and a button, what i wanna do is, when i hit the button, the values in textboxes should be inserted into DB. Would you please help me? Thanks in advance.

View 1 Replies View Related

Inserting 100 Records

Jan 17, 2007

How to insert 100 record at a time by explicit inserting of identity column i.e.., by setting identity column to false

View 4 Replies View Related

Inserting Data Into DB

May 5, 2007

Hi friends,I have one text box on my form.i need to insert the data from tat text box to DB without clicking on any button.Now i have written the code under text changed event of that text box.So it is inserting whenever i click on that form.Besides this i need to insert data when i close tat window.But it is not inserting when i close tat window.Plse help me.Thanks in advance
With RegardsLijo Rajan

View 1 Replies View Related

Inserting Data

Jun 6, 2007

I have created a form with several fields etc and validation.

After pressing the submit button i have a

if Page.IsValid then .....etc
But in this then bit I want to do a

INSERT the form details to the db.

I have done inserts etc via gridView etc but I just need a form that lets someone enter info and submit etc, so do not now where to or how to place this code to connect then insert etc

thanks

View 3 Replies View Related

Why Is This Trying Errors, (SQL Inserting)

Sep 18, 2007

Why on earth is this not working,  It WILL insert if there are NO apostheres (" ' "), but if I say like, "Cedric's Group" It will error out.  I thought this approach was suppose to handle this character?
Thanks for any insight, String sqlStr = "Insert into cardgroups (username,groupname,insertdt,groupid) values (@username,@groupname,@insertdt,@groupid)";

SqlCommand cmd = new SqlCommand(sqlStr, connect);

cmd.Parameters.AddWithValue("@username", Session["memberusername"].ToString());

cmd.Parameters.AddWithValue("@groupname",this.namebox.Text.ToString());

cmd.Parameters.AddWithValue("@insertdt", DateTime.Now.ToString());

cmd.Parameters.AddWithValue("@groupid", myGroupStr);

connect.Open();

cmd.ExecuteNonQuery();

connect.Close();
 

View 2 Replies View Related

Text Inserting

Oct 21, 2007

I fixed all the free text stuff but now I have another problem. I created a web app one page to enter data and anoter to display it. I have a multiple row text box and if you enter something with returns it it when you display the data it ignores the returns and puts everything on the same line  BTW the column type is text
 
example
 
this
"want to hest this out.
========================
 
now I am going to put in some test data and see how it comes out
 
finished"
 
will come out like this
"want to hest this out.========================now I am going to put in some test data and see how it comes out finished"
 
how do you fix this?

View 16 Replies View Related

Problem When Inserting

Nov 12, 2007

I want to insert a recorde into my table (2 column) : name and Id
id is a primary key and this is the error MSG im getting everytime im trying to insert a record
Error:Cannot insert explicit value for identity column in table 'Customer' when IDENTITY_INSERT is set to OFF.
what is the problem


here is the code :protected void Button2_Click(object sender, EventArgs e)
{
try
{string str = "data source=.;integrated security=true; initial catalog=NH_Project2";
SqlConnection conn = new SqlConnection(str);SqlCommand comm = new SqlCommand("insert into [Customer](Name,Id) values(@custName,@custId)", conn);
comm.CommandType = CommandType.Text;comm.Parameters.AddWithValue("@custName", TextBox1.Text);comm.Parameters.AddWithValue("@custId", TextBox2.Text);
conn.Open();
int rowaff = (int)comm.ExecuteNonQuery();if (rowaff == 1)
{Label4.Visible = true;Label4.Text = "one customer has added to our data base";
}
else
{Label4.Visible = false;Label4.Text = "not added try again";
}
}catch (Exception ex)
{ Response.Write("Error:" + ex.Message);
 
}
}

View 6 Replies View Related

Inserting Into More Than 1 Table

Jan 9, 2008

Hey all,
Quick question for ya.  If I wanted to insert 1 value into 1 table and another value into another table, how would I do that with closing connections and reopening and whatnot?  I am using Visual Web Dev and SQL server 2005 express.  I have been trying to mess around with it but I can't figure it out.  Here is the situation.
I want to insert a GroupName and GroupDescription that a user fills in in 2 text boxes named GroupNametxt and GroupDescriptiontxt.  This data will go into the "Group" table.
I then also want to Insert the data UserID (taken from the aspnet ID table), and GroupName from the Grouptxt.text into a GroupMembership table.
How would I do all this in 1 button click?  I know some basic TSQL but I don't know how to handle the opening and closing of connections and whatnot. 
Thanks,
Chris

View 2 Replies View Related

Inserting Just Times

Jan 20, 2008

When using a SQL Server DateTime column to store just times, e.g. '6:00 PM' I've noticed some weird inconsistency.
If I insert a time in a SQL statement, such as... INSERT INTO myTable (StartTime) VALUES ('6:00 PM')
It winds up going in as  '1/1/1900 6:00 PM'.  This is okay.  This is in fact what I want (unless of course the base day for sql server is in fact 12/30/1899, which is my next question).
If, on the other hand, I insert a time value by hand, using SQL Server Management Studio, then after I insert '6:00 PM' it winds up as '<Today's Date> 6:00 PM', i.e. '1/20/2008 6:00 PM'.
Also, if I insert it using a SQL Parameter, such as...
da.InsertCommand.Parameters.Add("@StartTime", SqlDbType.DateTime, 8, "StartTime")
...Then, if StartTime is 6:00 PM again, it also winds up going in as '<Today's Date> 6:00 PM'. 
Is there a way to control this behavior (other than to programmatically append a base date to the time I'm inserting)? 
Finally, what is the base day for SQL Server 2005?  Is it 1/1/1900 or 12/30/1899?  I think I've seen both. 
Thanks!
Aaron

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved