Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Thursday, March 29, 2012

Can't store chinese in SQL Database

update Food set FoodName = ' 杏仁' where ID = 100

in database as ?

Hi SuperM,

You should use Encoding support from your .NET Application.

To Encoding:

Encoding target = Encoding.GetEncoding( "GB18030" );
Byte[] buffer = target.GetBytes( text );
return Convert.ToBase64String( buffer );

From Encoding:

Encoding target = Encoding.GetEncoding( "GB18030" );
Byte[] buffer = Convert.FromBase64String( text );
return target.GetString( buffer );

You could use GB18030 to simplified or Big5 to traditional.

Later, value converted you send to store procedure.

Good Coding!

Javier Luna
http://guydotnetxmlwebservices.blogspot.com/

|||Or set the collation settings in SQL Server. If this is SQL Server 2000, you need to run the rebuildm.exe to change the current collation settings. But this will affect other databases in your server|||

Hi bass,

"But this will affect other databases in your server".

This could be very dangerous.

Good Coding!

Javier Luna
http://guydotnetxmlwebservices.blogspot.com/

|||

SuperM wrote:

update Food set FoodName = ' 杏仁' where ID = 100

in database as ?

I would recommend defining the data column as NVarchar, NChar, or NText, when at all possible when working with non-ascii characters.

Jimmy

|||I know what you mean but that should have been a part of the planning phase so that it would be considered in the deployment. Our applications use different collation settings as they are being used in different countries. So before we even create the databases, the SQL Sever settings have been defined properly.|||

thanks,

the field needs to store chinese which must define as NVarchar, NChar, or NText

The Insert SQL as

insert into Food (FoodName) values (N'杏仁' )

The Update SQL as

update Food set FoodName = N' 杏仁' where ID = 100

Tuesday, March 27, 2012

Can't start SQL 2000 after MS Update

Hi,
I recently installed several Windows Updates and security
patches. Now the SQL Server on my XP Pro development
machine won't start. The only message box that I get
when trying to restart is a message box:
SQL Server does not exist or access denied.
Any clues on how to fix this? I can't seem to find any
other references to this problem.
Regards,
DougSQL Server does not exist or access denied is a generic error message for a
failed connection.
If the MSSQLServer service is not started, then this makes sense.
Try running : Net start MSSQLServer
Check the account you're using to start MSSQLServer.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.|||I do have the SQLServer icon in the tray, stopped of
course.
I am logged in to the box as Doug with administrator
privledges, SQLServer is set to logon using Local System
account.
The exact message I get when trying to start from
Computer Management console is:
--
A connection could not be established to (local).
Reason: SQL Server does not exist or access denied.
ConnectionOpen (Connect())...
Please verify SQL Server is running and check your SQL
Server registration properties (by right-clicking on the
(local) node) and try again.
--
This had been working fine for months. Nothing that I
know of changed, other than these Windows Updates two or
three days ago when the problem started.
This is my development machine and I'm right in the
middle of a project, so I REALLY appreciate your help
here.
Doug

>--Original Message--
>SQL Server does not exist or access denied is a generic
error message for a
>failed connection.
>If the MSSQLServer service is not started, then this
makes sense.
>Try running : Net start MSSQLServer
>Check the account you're using to start MSSQLServer.
>Thanks,
>Kevin McDonnell
>Microsoft Corporation
>This posting is provided AS IS with no warranties, and
confers no rights.
>
>.
>|||Doug,
The MSSQLServer service needs to be running in order to connect.
Verify that the MSSQLServer service is running / started.
If you continue to have problems connecting, you should open a support case
with SQL Server.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.|||Kevin,
Please don't keep telling me that I need to start before
I can connect. I know that. As I mentioned before, I
CAN'T start or connect. THAT IS the problem.
Something happened, probably during an Update. I don't
know what else could have happened.
HELP. Please! Anyone!!!!
Doug

>--Original Message--
>Doug,
> The MSSQLServer service needs to be running in order
to connect.
>Verify that the MSSQLServer service is running / started.
>If you continue to have problems connecting, you should
open a support case
>with SQL Server.
>Thanks,
>Kevin McDonnell
>Microsoft Corporation
>This posting is provided AS IS with no warranties, and
confers no rights.
>
>.
>|||Doug,
Go into Control Panel to services and try to start the service from
there. If it doesn't start, check the event logs and your SQL Server
error log (the errorlog file in the SQL Server installation path \Log
folder).
-Sue
On Fri, 21 May 2004 13:42:27 -0700,
<anonymous@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>Kevin,
>Please don't keep telling me that I need to start before
>I can connect. I know that. As I mentioned before, I
>CAN'T start or connect. THAT IS the problem.
>Something happened, probably during an Update. I don't
>know what else could have happened.
>HELP. Please! Anyone!!!!
>Doug
>
>to connect.
>open a support case
>confers no rights.|||Hi! If you haven't solved your problem yet, try:
restoring your Windows XP to a previous state prior to the installation of
Windows patches. You can do this using System Restore of Windows XP.
Or, you can uninstall the patch(es) you had installed.
Or, try running sqlservr.exe from the command line and see if it generates a
more detailed error message.
HTH. =)
Ricky
<anonymous@.discussions.microsoft.com> wrote in message
news:105bb01c43f74$20bb2b70$a301280a@.phx
.gbl...[vbcol=seagreen]
> Kevin,
> Please don't keep telling me that I need to start before
> I can connect. I know that. As I mentioned before, I
> CAN'T start or connect. THAT IS the problem.
> Something happened, probably during an Update. I don't
> know what else could have happened.
> HELP. Please! Anyone!!!!
> Doug
>
> to connect.
> open a support case
> confers no rights.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.688 / Virus Database: 449 - Release Date: 5/18/2004

Sunday, February 12, 2012

Cant insert NULL to DateTime field

Hi I'm using DetailView and I have a text box which show the date. I have formated the date as shortDate {0:d} format. I want to insert/update null if that text box is empty.

I have tried putting null value in my Update statement in sqlDataSource. And I'm getting error saying can't convert varchar to smalldatetime.

If I don't set null value as above, some large date (01/01/2033) has been inserted in my database.

Can anyone help me?

Moe

insert DBNull.Value not "null"

Hope this help|||Thanks a lot.. :)|||Dear,Can you explain where I put this code? I am newbie and have the same with formview, and I wonder where to enter this DBNULL?Can you help please?|||

Here is sample code:

sqlStmt ="insert into Emp (FirstName,LastName,Date) Values (?,?,?) ";conString ="Provider=sqloledb.1;user id=sa;pwd=;database=northwind;data source=localhost";cn =new OleDbConnection(conString);cmd =new OleDbCommand(sqlStmt, cn) ;cmd.Parameters.Add(new OleDbParameter("@.FirstName", OleDbType.VarChar, 40));cmd.Parameters.Add(new OleDbParameter("@.LastName", OleDbType.VarChar, 40));cmd.Parameters.Add(new OleDbParameter("@.Date", OleDbType.Date)); cmd.Parameters["@.FirstName"].Value = txtFirstName.Text;cmd.Parameters["@.LastName"].Value = txtLastName.Text;if ((txtDate.Text =="") ){cmd.Parameters["@.Date"].Value = DBNull.Value;}else{cmd.Parameters["@.Date"].Value = DateTime.Parse(txtDate.Text);}cn.Open();cmd.ExecuteNonQuery();Label1.Text ="Record Inserted Succesfully";

Cant insert and delete

Hi,

Can anyone help me? I am using MSDE 2000 with VS.NET. I can SELECT from the database but i cant insert and delete and update. Below are my code

public static int Add(string tmpSql, string connectionString)

{

oleConn = new OleDbConnection(connectionString);

oleConn.Open();

oleTran = oleConn.BeginTransaction();

try

{

oleCom = new OleDbCommand(tmpSql, oleConn);

oleCom.Transaction = oleTran;

int a =oleCom.ExecuteNonQuery();

return(0);

}

catch

{

oleTran.Rollback();

return(1);

}

finally

{

oleConn.Close();

}

}

my int a give a value of 1 but when i look at the database the data is not inserted? but my primary key of the table did increase by one. what went wrong? is it due to my configuration which dun allow my to insert and update? help. Thank you

Please some1 pls help me or send me any useful link and i will figure out my self thanks..

|||Is it possible that you need to explicitly commit your transaction inside your try block before returning? In the example code on MSDN at the link below the transaction is explicitly committed.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbconnectionclassbegintransactiontopic.asp

Hope this helps,
Vaughn|||oh ya how can i forget that.. thanks alot.. Big Smile

Friday, February 10, 2012

Can't get SP3a installed

I'm trying to get SP3a installed on my computer, and it simply will not
update. Here's what SELECT @.@.VERSION returns:
Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48
Copyright (c) 1988-2000 Microsoft Corporation Developer Edition on Windows
NT 5.1 (Build 2600: Service Pack 2)
According to the MS web site, this is the original installation version. I
downloaded all 3 of the files at the end of the "Microsoft SQL Server 2000
Service Pack 3a" page, and followed the instructions and installed
sql2ksp3.exe first, then installed sql2kasp3.exe. I stopped the services,
and restarted the services, and SELECT @.@.VERSION still returns the same
exact thing as what is listed above. What did I do wrong here?
Thanks,
JesseHi
After running sql2ksp3.exe (it extracts to a directory), did you run the
setup.bat to install the SP?
Did the setup.bat run with errors?
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Jesse" wrote:
> I'm trying to get SP3a installed on my computer, and it simply will not
> update. Here's what SELECT @.@.VERSION returns:
> Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48
> Copyright (c) 1988-2000 Microsoft Corporation Developer Edition on Windows
> NT 5.1 (Build 2600: Service Pack 2)
> According to the MS web site, this is the original installation version. I
> downloaded all 3 of the files at the end of the "Microsoft SQL Server 2000
> Service Pack 3a" page, and followed the instructions and installed
> sql2ksp3.exe first, then installed sql2kasp3.exe. I stopped the services,
> and restarted the services, and SELECT @.@.VERSION still returns the same
> exact thing as what is listed above. What did I do wrong here?
> Thanks,
> Jesse
>
>|||No, I guess I missed the part about the setup.bat. I'm running that now.
Thanks,
Jesse
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:9ACC7775-75DD-409D-960B-1AA7507F63B5@.microsoft.com...
> Hi
> After running sql2ksp3.exe (it extracts to a directory), did you run the
> setup.bat to install the SP?
> Did the setup.bat run with errors?
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
>
> "Jesse" wrote:
>> I'm trying to get SP3a installed on my computer, and it simply will not
>> update. Here's what SELECT @.@.VERSION returns:
>> Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48
>> Copyright (c) 1988-2000 Microsoft Corporation Developer Edition on
>> Windows
>> NT 5.1 (Build 2600: Service Pack 2)
>> According to the MS web site, this is the original installation version.
>> I
>> downloaded all 3 of the files at the end of the "Microsoft SQL Server
>> 2000
>> Service Pack 3a" page, and followed the instructions and installed
>> sql2ksp3.exe first, then installed sql2kasp3.exe. I stopped the
>> services,
>> and restarted the services, and SELECT @.@.VERSION still returns the same
>> exact thing as what is listed above. What did I do wrong here?
>> Thanks,
>> Jesse
>>|||As you found out, the running of the EXE only extracts the files to actually
run.
Have fun.
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Jesse" <nospam@.fake.com> wrote in message
news:%231LnLWcbFHA.3464@.tk2msftngp13.phx.gbl...
> No, I guess I missed the part about the setup.bat. I'm running that now.
> Thanks,
> Jesse
> "Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
> news:9ACC7775-75DD-409D-960B-1AA7507F63B5@.microsoft.com...
>> Hi
>> After running sql2ksp3.exe (it extracts to a directory), did you run the
>> setup.bat to install the SP?
>> Did the setup.bat run with errors?
>> Regards
>> --
>> Mike Epprecht, Microsoft SQL Server MVP
>> Zurich, Switzerland
>> MVP Program: http://www.microsoft.com/mvp
>> Blog: http://www.msmvps.com/epprecht/
>>
>> "Jesse" wrote:
>> I'm trying to get SP3a installed on my computer, and it simply will not
>> update. Here's what SELECT @.@.VERSION returns:
>> Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48
>> Copyright (c) 1988-2000 Microsoft Corporation Developer Edition on
>> Windows
>> NT 5.1 (Build 2600: Service Pack 2)
>> According to the MS web site, this is the original installation version.
>> I
>> downloaded all 3 of the files at the end of the "Microsoft SQL Server
>> 2000
>> Service Pack 3a" page, and followed the instructions and installed
>> sql2ksp3.exe first, then installed sql2kasp3.exe. I stopped the
>> services,
>> and restarted the services, and SELECT @.@.VERSION still returns the same
>> exact thing as what is listed above. What did I do wrong here?
>> Thanks,
>> Jesse
>>
>