|
Are you saying that DBNull.Value does not work?
|
|
|
|
|
Yes, I tried DBNull.Value, SqlDateTime.Null,"",NULL," "....
All of them failed.
|
|
|
|
|
Are you sure the field is nullable?
|
|
|
|
|
I think the field is nullable
as I can leave it intact (blank) without problems while
inserting values to other fields in the same row
when opening it with Access .
It seems you got loads of experience.
Is that possible to talk to you of
this problem on phone?
Mei.
0044 792 531 8977
|
|
|
|
|
I am trying to bulk insert data from a text file to a temp table. The bulk insert is unable to recognise the linefedd character and tries to insert complete data in one column.
Can anyone help me solve this problem.
|
|
|
|
|
Try and alter the line break from {CR}{LF} to {CR} or {LR}. Some Unix files can have strange formating for new carriage returns.
Failing that if you can use anything as row delimiter such as |||@@@|||, as long as you can alter the orginal text file.
|
|
|
|
|
Thanks for ths reply, but none of them worked. It works when downloaded through command prompt ftp command, but not when downloaded using our ftp code written in VB.net.
|
|
|
|
|
Hi,
I wonder which is better using direct sql statments directly in the code or writing stored procedures inside the SQL Server database? What are the advantages and disadvantages of each?
Thank you
|
|
|
|
|
stored procedures are compiled and operated much faster than free line code.
Store procedures are also more secure
Store procedure also let you modify the back end business logic without effecting your web or client applicated.
Store procedures can be unit tested as a seperate business logic.
Store procedure can return scaler values, tables , or action as action code.
Store procedures can have error trapping and rollbacks if multiple tables need to be updates.
Don't use free line SQL unless you can avoid it.
|
|
|
|
|
Stored Procedures are better in my opinion.
Here are a couple of reasons:
SPs mean that you can revoke the permissions on direct table access pushing everything through SPs. This means the only actions that an application can perform are only the actions the SPs permit.
SPs can do additional checking of the data. This allows the database to weed out potentially dangerous data as part of a layered security approach. e.g. The application weeds out potentially harmful data first, but if that security layer should be compromised somehow the database itself has a layers of security to prevent dangerous actions - this includes logic within the SPs
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Show him your article colin.
<italic>Work hard, Work effectively.
|
|
|
|
|
Hello everyone,How do i use c# control sqlserver backup and restore? Where side this knowledge can be found? Can I find it in msdn? Tell me! Thank you!
|
|
|
|
|
There are SQL commands to BACKUP[^] and RESTORE[^] databases. You can find them in MSDN quite easily.
Next, all you need to do is create a string with the appropriate command in it and use SqlCommand. Like this:
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand(myCommandString, myConnection);
myCommand.CommandTimeout = 3600;
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
It is as easy as that. You need to fill in the connection string and the command string with the appropriate values. If your backup or restore is likely to take more than one hour you might want to change the CommandTimeout as well.
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Thats a good solution. But if you want you can use SQL DMO to achieve this.
Just add a reference to sqldmo.dll and make method calls on it to backup and restore.
Public Function DB_Backup(ByVal nServer_Name As String, _
ByVal nDB_Name As String, _
ByVal nDB_Login As String, ByVal nDB_Password As String, _
ByVal nBack_Dev As String, ByVal nBack_Set As String, _
ByVal nBack_Desc As String) As Boolean
' nServer_Name = SQL server name
' nDB_Name = Database name
' nDB_Login = Login name
' nDB_Password = Password
' nBack_Dev =Backup device name
' nBack_Set = Backup set name
' nBack_Desc = Backup discription
Dim oBackup As SQLDMO.Backup
On Error GoTo ErrorHandler
Set oBackup = CreateObject("SQLDMO.Backup")
If Connect_SQLDB(nServer_Name, nDB_Login, nDB_Password) Then
oBackup.Devices = "[" & nBack_Dev & "]"
oBackup.Database = nDB_Name
oBackup.BackupSetName = nBack_Set
oBackup.BackupSetDescription = nBack_Desc
oBackup.SQLBackup oSQLServer
oSQLServer.DisConnect
DB_Backup = True
End If
Exit Function
ErrorHandler:
DB_Backup = False
End Function
Private Function Connect_SQLDB(ByVal nServer_Name As String, _
ByVal nDB_Login As String, _
ByVal nDB_Password As String) As Boolean
' nServer_Name = SQL server name
' nDB_Login = Login name
' nDB_Password = Password
Set oSQLServer = CreateObject("SQLDMO.SQLServer")
On Error GoTo ErrorHandler
Connect_SQLDB = False
oSQLServer.Connect nServer_Name, nDB_Login, nDB_Password
Connect_SQLDB = True
Exit Function
ErrorHandler:
oSQLServer.DisConnect
Connect_SQLDB = False
End Function
Also check this
http://www.codersource.net/csharp_sqldmo_sqlserver.aspx
|
|
|
|
|
Also
C:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\sqldmo\unzip_sqldmo.exe
unzip archive and go to
E:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\sqldmo\vb\BackupDevice
or
E:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\sqldmo\vb\VerifyBackup
VB6,C#
|
|
|
|
|
My Environment: MySQL Database, ADO, MSVC6, MS DataGrid.
Datagrid is being used to display data from three tables, joined by their primary keys.
Problem: User wants to be able to edit the data in the grid itself. When he does, and tried to move to another record, the grid displays the message "Insufficient Key Column Information for updating or refreshing". User is not willing to have me bring up the row data in a dialog to edit.
Even Bigger Problem: I need to keep this user happy!
Schema:
Table_1: ID (AutoNumber, PK), Field_A (Varchar), Field_B (Varchar)
Table_2: ID (Autonumber, PK), Field_C (Varchar), Field_D (Integer)
Table_3: ID (Autonumber, PK), Field_E (Double)
SQL for Grid: SELECT Table_1.ID, Table_1.Field_A, Table_2.Field_C, Table_3.Field_E FROM (Table_1 INNER JOIN Table_2 ON Table_1.ID=Table_2.ID) INNER JOIN Table_3 ON Table_1.ID=Table_3.ID ORDER BY Table_1.Field_A
MS KB: There is no duplication of field names except ID. ID is always the primary key. The ID field is not being updated. Field_A is.
ADO: I have tried using both adUseClient and adUseServer as the cursor location, for both the connection object and the recordset object. Has not made any difference.
Can I set this up so that enough key column information is available for the update? Is this even possible?
|
|
|
|
|
From MSDN:
When updating an ActiveX Data Objects (ADO) recordset, an error occurs if the recordset, based on a SHAPE command, joins two tables where the primary key of one table has the same name as a column name of the other table. The following error appears:
Run-time error '-2147467259 (80004005)':
Insufficient key column information for updating or refreshing.
You can try renaming the primary keys.
|
|
|
|
|
Actually, I had tried that already, it did not work. I am beginning to think this is something so deep inside Microsoft Cursor engine, that there may not be an easy work-around. The SQL I used was not a SHAPE sql anyway.
My solution so far has been to switch to a disconnected recordset, and intercept update notifications from the grid. Then I have to write some code for a Lazy Writer to actually update the database with the changes from the grid.
|
|
|
|
|
I have a Access database that I wrote a VB.net program for. I want to set it up so I can seach it using the indexof method. I gotten as far as the listbox,inputbox and the button, but I'm pretty much running around in circles with the code. Anyone know how to do this?
BINARY
|
|
|
|
|
You don't search a database with the IndexOf() method, that is for arrays.
I suspect that what you are tying to do is to use the controls to select an item so that you can then select the appropriate data from the database. Is this the case? You need to describe what you are doing more clearly so we can help you better.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
I want to be able to type a string into an input box or text box that would match itself with a field in the database then show me the results in a listbox. Then by clicking on the list box pull up the entire record.
BINARY
|
|
|
|
|
I am working on an asp script that pulls data from ms sql. In one part, it pulls the days of the week that an event occurs on. If I do something like this:
select dayofweek from schedule where id=5
I get:
---------
dayofweek
---------
M
---------
T
---------
W
---------
What I need is a sql statement that does something like this:
---------
dayofweek
---------
M,T,W
---------
Is there a way to select them into one record like this even though they are stored in multiple rows in the table?
Thanks,
Jim
|
|
|
|
|
Try this T SQL script (you ca make a SQL Server function)
--parameter @id
DECLARE @id INT
SET @id = 5
DECLARE @ssum NVARCHAR(255)
DECLARE @dayofweek NVARCHAR(25)
SET @ssum = ''
DECLARE crs CURSOR FOR SELECT DAYOFWEEK FROM schedule WHERE ID = @id
OPEN crs
FETCH NEXT FROM crs INTO @dayofweek
WHILE( @@FETCH_STATUS = 0 )
BEGIN
SET @ssum = @ssum + ',' + @dayofweek
FETCH NEXT FROM crs INTO @dayofweek
END
CLOSE crs
DEALLOCATE crs
IF( LEN(@ssum) != 0 )
SET @ssum = SUBSTRING(@ssum,2,255)
PRINT @ssum
|
|
|
|
|
|
I need to do exactly the same thing, but my result needs to print in a textbox in a SQL Server 2000 Reporting Services Report. I created a function in the Custom Code area for the report, but I get the message: "Statement is not valid inside a method." Can you tell me how to make your code work in Reporting Services?
|
|
|
|