如何删除空行 [英] how to delete empty row

查看:103
本文介绍了如何删除空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中遇到了一个问题,问题是我有10个空行,其中没有任何数据,这是因为我单击了许多插入按钮插入数据.请给我显示编码,以删除空白行.对于您的信息我有表名是Bundle和2列,这是名称和类型.请给我例子.这是我的编码正确吗?

 connection.ConnectionString = " 
尝试

connection.Open()
cmd = 新建 SqlCommand(" & "  '",连接)
ra = cmd.ExecuteNonQuery()
MsgBox(" ,MsgBoxStyle.Information, 记录已删除="& ra)

捕获,例如 As 异常
MsgBox(" )
结束 尝试
connection.Close()



添加了代码"标记-losmac [/编辑]

解决方案

使用此查询"DELETE FROM bundle WHERE type is Null or type = ''''"


删除空行,修复数据库,以便您不能将NULL数据添加到逻辑上不支持它的字段中,然后修复代码,从而避免插入空记录.


hi, i got a probleam with my database, the probleam is i have 10 of empty row which doesnt not have any data, this is happen because i click to many insert button insert data. Please show me the coding should i use to delete my empty row. For you info i have table name is Bundle and 2 column which is name and type . Please give me example please.Is this my coding correct

connection.ConnectionString = " Data Source=Danawa;Initial Catalog=Store;Integrated Security=True"
Try

connection.Open()
cmd = New SqlCommand("DELETE FROM bundle WHERE type = is NUll'" & Me.txtsearchbundle.Text & "' ", connection)
ra = cmd.ExecuteNonQuery()
MsgBox("Category Are Deleted!!", MsgBoxStyle.Information, "Record Deleted = " & ra)

Catch ex As Exception
MsgBox("Record Failed to Delete")
End Try
connection.Close()



[Edit]Added "code" tag - losmac[/Edit]

解决方案

Use this query "DELETE FROM bundle WHERE type is Null or type = ''''"


Once you get the empty rows deleted, fix your database so you cannot add NULL data to fields that don''t logically support it and then fix your code so you''re not inserting empty records.


这篇关于如何删除空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆