|
Hi All,
I am getting a strange error while establishing connection with sqlserver.
i written the following code to establish the connection
string sqlStatement = "select * from Student_Table";
String dataBaseConnection = "Data Source=DREDDY9/SQLEXPRESS;Initial Catalog=SampleDataBase;Integrated Security=SSPI";
SqlConnection myConnection = new SqlConnection(dataBaseConnection);
SqlCommand myCommand = new SqlCommand(sqlStatement, myConnection);
SqlDataReader dr;
myConnection.Open();
dr = myCommand.ExecuteReader();
if(dr!=null)
{
Response.Write("Successfully Executed");
}
myConnection.Close();
To resolve this i tried with enabling local and remote connections and i enabled sql server browser.
but no use
any body is having any solution. please shere it.
|
|
|
|
|
What is the error?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
what kind of error you are facing are you enable to connect if so then try
Data Source=./SQLEXPRESS instead off Data Source=DREDDY9/SQLEXPRESS
also check your protocols you are connecting with tcp/ip or named pipes and the user from which you are going to connect should have rights to connect to the db.
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
look out for slash it should be \ not /
Data Source=DREDDY9/SQLEXPRESS;
Data Source=DREDDY9\SQLEXPRESS;
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
I have the following table (ccpoc)
poc_cod varchar(10)
poc_cod_asc varchar(10)
poc_desc varchar(40)
With the following data
poc_cod poc_cod_asc poc_desc
1 12 Coiso
1 13 Coisa
1 14 Coisinhas
And I'm trying the following query
UPDATE ccpoc SET poc_cod='133', poc_cod_asc='13', poc_desc='Coiso 133' WHERE poc_cod='13' AND poc_desc='Coiso 13' AND poc_cod_asc='1'
I'm querying the server with an ExecuteNonQuery in C#, and everything seems to go fine. No errors, no exceptions, everything runs well. The problem is that data in the table does not change!
Anybody has any idea what might be happening?
Best regards
Fratelli
|
|
|
|
|
I guess you should give a try to these:
1. Run SQL profiler to see what query is actually run on your table.
2. Run a select statement with same where clause to check if there are any rows matching the criteria.
3. If you are using transactions, check if you have committed it or not.
4. Does the same query when run through Management studio works?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
AndreFratelli wrote: WHERE poc_cod='13' AND poc_desc='Coiso 13' AND poc_cod_asc='1'
none of the records shown match this.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Yes, I noticed already. Lame mistake
Fratelli
|
|
|
|
|
With the following data
poc_cod poc_cod_asc poc_desc
1 12 Coiso
1 13 Coisa
1 14 Coisinhas
And I'm trying the following query
WHERE poc_cod='13' AND poc_desc='Coiso 13' AND poc_cod_asc='1'
in your abv given data their is no row having poc_desc='Coiso 13' , so how come will it update, no doubt the results would be zero.
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Hi,
I have a c# application that uses a MySql database, the problem that after a period of inactivity (8 hours) or when connection to the server where database is host is lost, the connection to the database is closed and database queries cannot be executed. how can i enable the auto reconnect to the database.
Best regards.
Keep it simple, stupid!
|
|
|
|
|
Through a Timer in your C# code.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Shouldnot disconnected architecture will resolve it
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
I was also thinking why would you need an active connection "forever". Then thought there might be something in his application that desperately needs it and hence the reply.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
why are you making your connection always active means you dont need to connect to db always, you should connect to the db when you need to connect at the time of doing any CRUD operations,it will resolve your inactivity problem.
CCreate
R Retrieve
UUpdate
DDelete
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
I have variable @keys which value is
Declare @keys varchar(max)
set @keys = '44,333,234,125,3,3445'
I want to split above variable in following from
44
333
234
125
3
3445
the length of @keys can be 4000 character
Dre@m is not th@t wh@t u see in sleep.Dre@m is the thing which does not allow u to sleep
modified on Saturday, September 12, 2009 9:52 AM
|
|
|
|
|
DECLARE @NextString NVARCHAR(40)
DECLARE @Pos INT
DECLARE @NextPos INT
DECLARE @String NVARCHAR(40)
DECLARE @Delimiter NVARCHAR(40)
SET @String ='softdev,sup'
SET @Delimiter = ','
SET @String = @String + @Delimiter
SET @Pos = charindex(@Delimiter,@String)
WHILE (@pos <> 0)
BEGIN
SET @NextString = substring(@String,1,@Pos - 1)
SELECT @NextString -- Show Results
SET @String = substring(@String,@pos+1,len(@String))
SET @pos = charindex(@Delimiter,@String)
END
Result
- Softdev
- sup
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
do a string replace:
pseudocode:
string sLineFeed = "\n"; (or vbCrLf for Visual Basic or <br> for HTML)
string sSource = "A,B,C,D,E,F,G";
string sDestintion = replace(sSource,",",sLineFeed)
Rob
http://tagyurit.com
r
|
|
|
|
|
Use this function :
CREATE FUNCTION [dbo].[FN_STRINGTOTABLE](@P_STRING VARCHAR(8000), @P_DELIMITER CHAR(1))
RETURNS @P_TEMPTABLE TABLE
(ITEMS VARCHAR(8000))
AS
BEGIN
DECLARE @V_IDX INT
DECLARE @V_SLICE VARCHAR(8000)
SELECT @V_IDX = 1
IF LEN(@P_STRING)<1 OR @P_STRING IS NULL RETURN
WHILE @V_IDX != 0
BEGIN
SET @V_IDX = CHARINDEX(@P_DELIMITER,@P_STRING)
IF @V_IDX !=0
SET @V_SLICE = LEFT(@P_STRING,@V_IDX - 1)
ELSE
SET @V_SLICE = @P_STRING
IF(LEN(@V_SLICE)>0)
INSERT INTO @P_TEMPTABLE(ITEMS) VALUES(@V_SLICE)
SET @P_STRING = RIGHT(@P_STRING,LEN(@P_STRING) - @V_IDX)
IF LEN(@P_STRING) = 0 BREAK
END
RETURN
END
This will work great.
|
|
|
|
|
Why? 
|
|
|
|
|
I have a source of a 2007 excel workbook and of the data is there that needs to be there for the import to the SQL 2008 destination table. i.e all "not null" fields are populated and mapped except the primary key which happens to be a unique identifier datatype.
I have tried creating a column using the NEWSEQUENTIALID() function in the first row.....that works for inserting nulls into a "shell" db but it fails everytime on the destination table that has a primaery key on the field and unique identifer as the data type.
Question:
How do I generate the GUIDS (unique identifers) from a DTSX package?
Is there a work around? I have spent the whole night trying everything except the right way.
Any help is greatly appreciated.
Thanks,
Regards,
Hulicat
|
|
|
|
|
Hulicat wrote: How do I generate the GUIDS (unique identifers) from a DTSX package?
ExecuteSql task with a call to NEWID()
Script Task with a call to new Guid()
take your pick.
|
|
|
|
|
hi every body
im having a big problem.
icant connect to my data base.
i have this error
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
i dont know what to do please help me
|
|
|
|
|
Is Remote Connection enabled for your SQL server instance?
Goto
Configuration Tools >> SQL SErver Surface Area Configuration >> Surface area configuration for services and connections
Enable the remote connection by selecting local and remote connection (using both TCP/IP and named pipes)
HTH
|
|
|
|
|
thanks for your reply but it didnt work i try it many times before do u have any thing else?
|
|
|
|